Back to index

salome-med  6.5.0
am2cmake.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # This library is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU Lesser General Public
00006 # License as published by the Free Software Foundation; either
00007 # version 2.1 of the License.
00008 #
00009 # This library is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 # Lesser General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU Lesser General Public
00015 # License along with this library; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 #
00018 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 #
00020 
00021 import re
00022 
00023 # ----
00024 # A set of regular expressions used ...
00025 # ----
00026 
00027 p_multiline = re.compile(r"""
00028 \\           # One backslash
00029 \s*          # 0 or more space
00030 \n           # One CR
00031 """, re.VERBOSE)
00032 
00033 p_dollar = re.compile(r"""
00034 \$\(           # a $ then a (
00035 (?P<val>       # open the group val
00036 [^)]*          # the group contain 0 or more non ) characters
00037 )              # close the group
00038 \)             # a ) at the end
00039 """, re.VERBOSE)
00040 
00041 p_arobas = re.compile(r"""
00042 @              # a @
00043 (?P<val>       # open the group val
00044 [^@]*            # the group contain 0 or more non @ characters
00045 )              # close the group
00046 @              # a @ at the end
00047 """, re.VERBOSE)
00048 
00049 p_if = re.compile(r"""
00050 ^          # beginning of the string
00051 \s*        # 0 or more space
00052 if         # an if
00053 \s+        # 1 or more space
00054 (?P<val>   # open the group val
00055 .+         # the group contain 1 or more non space characters
00056 )          # close the group
00057 """, re.VERBOSE)
00058 
00059 p_else = re.compile(r"""
00060 ^          # beginning of the line
00061 \s*        # 0 or more space
00062 else       #
00063 \s*        # 0 or more space
00064 """, re.VERBOSE)
00065 
00066 p_endif = re.compile(r"""
00067 ^          # beginning of the line
00068 \s*        # 0 or more space
00069 endif      # a endif
00070 \s*        # 0 or more space
00071 """, re.VERBOSE)
00072 
00073 p_attribution = re.compile(r"""
00074 ^              # beginning of the line
00075 (?P<spaces>    # open the group spaces
00076 \s*            # 0 or more space
00077 )              # close the group
00078 (?P<key>       # open the group key
00079 \w+            # the group contain 1 or more alphanumeric characters
00080 )              # close the group
00081 \s*            # 0 or more space
00082 (?P<method>    # open the group method
00083 \+?            # 0 or 1 +
00084 =              # One =
00085 )              # close the group
00086 (?P<value>     # open the group value
00087 .*             # 0 or more any characters 
00088 )              # close the group
00089 """, re.VERBOSE)
00090 
00091 # -----
00092 
00093 class CMakeFile(object):
00094     
00095     def __init__(self, the_root, root, dirs, files, f, module):
00096         #
00097         self.the_root = the_root
00098         self.root = root
00099         self.dirs = dirs
00100         self.files = files
00101         self.module = module
00102         #
00103         from os.path import join
00104         self.amFile = join(root, f)
00105         self.listsFile = join(root, "CMakeLists.txt")
00106         #
00107         self.parseFile()
00108         #
00109         return
00110     
00111     def parseFile(self):
00112         
00113         # --
00114         # Read the Makefile.am file
00115         # --
00116         amFile = self.amFile
00117         stream = open(amFile)
00118         content = stream.read()
00119         stream.close()
00120         
00121         # --
00122         # Replace the composed lines separated by "\\n" by an unique line
00123         # --
00124         content = p_multiline.sub(r' ', content)
00125         
00126         # --
00127         # Compatibility netgen plugin
00128         # --
00129         content = content.replace("../NETGEN/libNETGEN.la", "${NETGEN_LIBS}")
00130         
00131         # --
00132         cas_list = [
00133             "BinLPlugin",
00134             "BinPlugin",
00135             "BinTObjPlugin",
00136             "BinXCAFPlugin",
00137             "FWOSPlugin",
00138             "PTKernel",
00139             "StdLPlugin",
00140             "StdPlugin",
00141             "TKAdvTools",
00142             "TKBin",
00143             "TKBinL",
00144             "TKBinTObj",
00145             "TKBinXCAF",
00146             "TKBO",
00147             "TKBool",
00148             "TKBRep",
00149             "TKCAF",
00150             "TKCDF",
00151             "TKernel",
00152             "TKFeat",
00153             "TKFillet",
00154             "TKG2d",
00155             "TKG3d",
00156             "TKGeomAlgo",
00157             "TKGeomBase",
00158             "TKHLR",
00159             "TKIGES",
00160             "TKLCAF",
00161             "TKMath",
00162             "TKMesh",
00163             "TKMeshVS",
00164             "TKNIS",
00165             "TKOffset",
00166             "TKOpenGl",
00167             "TKPCAF",
00168             "TKPLCAF",
00169             "TKPrim",
00170             "TKPShape",
00171             "TKService",
00172             "TKShapeSchema",
00173             "TKShHealing",
00174             "TKStdLSchema",
00175             "TKStdSchema",
00176             "TKSTEP",
00177             "TKSTEP209",
00178             "TKSTEPAttr",
00179             "TKSTEPBase",
00180             "TKSTL",
00181             "TKTObj",
00182             "TKTopAlgo",
00183             "TKV2d",
00184             "TKV3d",
00185             "TKVRML",
00186             "TKXCAF",
00187             "TKXCAFSchema",
00188             "TKXDEIGES",
00189             "TKXDESTEP",
00190             "TKXMesh",
00191             "TKXml",
00192             "TKXmlL",
00193             "TKXmlTObj",
00194             "TKXmlXCAF",
00195             "TKXSBase",
00196             "XCAFPlugin",
00197             "XmlLPlugin",
00198             "XmlPlugin",
00199             "XmlTObjPlugin",
00200             "XmlXCAFPlugin",
00201             ]
00202         vtk_list = [
00203             "vtkCommonPythonD",
00204             "vtkGraphicsPythonD",
00205             "vtkImagingPythonD",
00206             "vtkPythonCore",
00207             ]
00208         kernel_list  = [
00209             "CalciumC",
00210             "DF",
00211             "Launcher",
00212             "LifeCycleCORBATest",
00213             "NamingServiceTest",
00214             "OpUtil",
00215             "Registry",
00216             "ResourcesManager",
00217             "SALOMEBasics",
00218             "SalomeCatalog",
00219             "SalomeCommunication",
00220             "SalomeContainer",
00221             "SalomeDatastream",
00222             "SalomeDSCContainer",
00223             "SalomeDSClient",
00224             "SalomeDSCSupervBasic",
00225             "SalomeDSCSuperv",
00226             "SalomeDSImpl",
00227             "SALOMEDSImplTest",
00228             "SalomeDS",
00229             "SALOMEDSTest",
00230             "SalomeGenericObj",
00231             "SalomeHDFPersist",
00232             "SalomeIDLKernel",
00233             "SalomeLauncher",
00234             "SalomeLifeCycleCORBA",
00235             "SALOMELocalTrace",
00236             "SALOMELocalTraceTest",
00237             "SalomeLoggerServer",
00238             "SalomeMPIContainer",
00239             "SalomeNotification",
00240             "SalomeNS",
00241             "SalomeResourcesManager",
00242             "SalomeTestComponentEngine",
00243             "SalomeTestMPIComponentEngine",
00244             "SALOMETraceCollectorTest",
00245             "TOOLSDS",
00246             "UtilsTest",
00247             "with_loggerTraceCollector",
00248             ]
00249         gui_list = [
00250             "caf",
00251             "CAM",
00252             "CASCatch",
00253             "DDS",
00254             "Event",
00255             "GLViewer",
00256             "LightApp",
00257             "LogWindow",
00258             "ObjBrowser",
00259             "OCCViewer",
00260             "OpenGLUtils",
00261             "Plot2d",
00262             "PyConsole",
00263             "PyInterp",
00264             "QDS",
00265             "qtx",
00266             "QxScene",
00267             "SalomeApp",
00268             "SalomeAppTest",
00269             "SalomeIDLGUI",
00270             "SalomeObject",
00271             "SalomePrs",
00272             "SalomePyQtGUILight",
00273             "SalomePyQtGUI",
00274             "SalomePyQt",
00275             "SalomePy",
00276             "SalomeSession",
00277             "SalomeStyle",
00278             "SOCC",
00279             "SPlot2d",
00280             "std",
00281             "SUITApp",
00282             "suit",
00283             "SUPERVGraph",
00284             "SVTK",
00285             "ToolsGUI",
00286             "ViewerTools",
00287             "VTKViewer",
00288             ]
00289         geom_list = [
00290             "AdvancedGUI",
00291             "BasicGUI",
00292             "BlocksGUI",
00293             "BooleanGUI",
00294             "BREPExport",
00295             "BREPImport",
00296             "BuildGUI",
00297             "DisplayGUI",
00298             "DlgRef",
00299             "EntityGUI",
00300             "GenerationGUI",
00301             "GEOMAlgo",
00302             "GEOMArchimede",
00303             "GEOMBase",
00304             "GEOMbasic",
00305             "GEOMClient",
00306             "GEOMEngine",
00307             "GEOMFiltersSelection",
00308             "GEOMimpl",
00309             "GEOMObject",
00310             "GEOMSketcher",
00311             "GEOM",
00312             "GEOM_SupervEngine",
00313             "GEOMToolsGUI",
00314             "GroupGUI",
00315             "IGESExport",
00316             "IGESImport",
00317             "MeasureGUI",
00318             "NMTDS",
00319             "NMTTools",
00320             "OCC2VTK",
00321             "OperationGUI",
00322             "PrimitiveGUI",
00323             "RepairGUI",
00324             "SalomeIDLGEOM",
00325             "ShHealOper",
00326             "STEPExport",
00327             "STEPImport",
00328             "STLExport",
00329             "TransformationGUI",
00330             "VTKExport",
00331             ]
00332         med_list = [
00333             "interpkernel",
00334             "InterpKernelTest",
00335             "MEDClientcmodule",
00336             "medcouplingclient",
00337             "medcouplingcorba",
00338             "medcouplingremapper",
00339             "medcoupling",
00340             "MEDEngine",
00341             "medloader",
00342             "MEDMEMCppTest",
00343             "MEDMEMImpl",
00344             "medmem",
00345             "MED",
00346             "medsplitter",
00347             "MEDSPLITTERTest",
00348             "med_V2_1",
00349             "MEDWrapperBase",
00350             "MEDWrapper",
00351             "MEDWrapper_V2_1",
00352             "MEDWrapper_V2_2",
00353             "paramedcouplingcorba",
00354             "paramedloader",
00355             "paramedmemcompo",
00356             "paramedmem",
00357             "ParaMEDMEMTest",
00358             "SalomeIDLMED",
00359             "SalomeIDLMEDTests",
00360             ]
00361         smesh_list = [
00362             "GeomSelectionTools",
00363             "MEFISTO2D",
00364             "MeshDriverDAT",
00365             "MeshDriverMED",
00366             "MeshDriver",
00367             "MeshDriverSTL",
00368             "MeshDriverUNV",
00369             "SalomeIDLSMESH",
00370             "SMDS",
00371             "SMESHClient",
00372             "SMESHControls",
00373             "SMESHDS",
00374             "SMESHEngine",
00375             "SMESHFiltersSelection",
00376             "SMESHimpl",
00377             "SMESHObject",
00378             "SMESH",
00379             "StdMeshersEngine",
00380             "StdMeshersGUI",
00381             "StdMeshers",
00382             ]
00383         full_list  = cas_list + vtk_list
00384         full_list += kernel_list + gui_list
00385         full_list += geom_list + med_list + smesh_list
00386         # --
00387         # E.A. : sort by len before substitution ...
00388         # Why ? Thing to "-lMEDWrapper" then "-lMEDWrapper_V2_1" substition
00389         # And you understand ...
00390         # --
00391         full_list.sort(cmp = lambda x, y : cmp(len(y), len(x)))
00392         # --
00393         for key in full_list:
00394             content = content.replace("-l%s"%(key), "${%s}"%(key))
00395             pass
00396         
00397         # --
00398         # Split content in lines to treat each one separately
00399         # --
00400         lines = content.split('\n')
00401         
00402         # --
00403         # newlines contains the lines of the future CMakeLists.txt file
00404         # --
00405         newlines = []
00406         
00407         # --
00408         # opened_ifs is used to deals with nested conditionnals
00409         # --
00410         opened_ifs = []
00411         
00412         # --
00413         # the __thedict__ dictionnary contains key, val
00414         # of the Makefile.am file
00415         # --
00416         self.__thedict__ = {}
00417         
00418         # --
00419         # Initialize file ... mainly includes other cmake files
00420         # --
00421         self.initialize(newlines)
00422         
00423         # --
00424         # Do the job for each line
00425         # --
00426         for line in lines:
00427             self.treatLine(line, newlines, opened_ifs)
00428             pass
00429         
00430         # --
00431         # Finalize file ... it is in here the cmake job is done
00432         # --
00433         self.finalize(newlines)
00434         
00435         # --
00436         # Concatenate newlines into content
00437         # --
00438         content = '\n'.join(newlines)
00439         
00440         # --
00441         # Add a CR at end if necessary
00442         # --
00443         lines = content.split('\n')
00444         # lines = [ l.strip() for l in lines ]
00445         if len(lines[-1]) != 0:
00446             lines.append('')
00447             pass
00448         content = '\n'.join(lines)
00449         
00450         # --
00451         self.content = content
00452         
00453         # --
00454         return
00455     
00456     def initialize(self, newlines):
00457         if self.root == self.the_root:
00458             # --
00459             newlines.append("""
00460             CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
00461             IF(COMMAND cmake_policy)
00462             cmake_policy(SET CMP0003 NEW)
00463             ENDIF(COMMAND cmake_policy)
00464             """)
00465             # --
00466             newlines.append("""
00467             ENABLE_TESTING()
00468             """)
00469             # --
00470             newlines.append("""
00471             SET(MODULE %s)
00472             """%(self.module.upper()))
00473             # --
00474             if self.module == "netgen":
00475                 newlines.append("""
00476                 INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindPLATFORM.cmake)
00477                 INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindCAS.cmake)
00478                 """)
00479             else:
00480                 if self.module == "kernel":
00481                     newlines.append("""
00482                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00483                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00484                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00485                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00486                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00487                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00488                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00489                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00490                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00491                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00492                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00493                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00494                     """)
00495                     pass
00496                 else:
00497                     if self.module == "med":
00498                         newlines.append("""
00499                         SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
00500                         IF(KERNEL_ROOT_DIR)
00501                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00502                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00503                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00504                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00505                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00506                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00507                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00508                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00509                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00510                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00511                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00512                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00513                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
00514                         ELSE(KERNEL_ROOT_DIR)
00515                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindPLATFORM.cmake)
00516                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindMPI.cmake)
00517                         ENDIF(KERNEL_ROOT_DIR)
00518                         """)
00519                     else:
00520                         newlines.append("""
00521                         SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
00522                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00523                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00524                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00525                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00526                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00527                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00528                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00529                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00530                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00531                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00532                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00533                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00534                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
00535                         """)
00536                         pass
00537                     if self.module == "gui":
00538                         newlines.append("""
00539                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindCAS.cmake)
00540                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQT4.cmake)
00541                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
00542                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindVTK.cmake)
00543                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQWT.cmake)
00544                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
00545                         """)
00546                     else:
00547                         newlines.append("""
00548                         SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR})
00549                         IF(GUI_ROOT_DIR)
00550                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindCAS.cmake)
00551                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQT4.cmake)
00552                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
00553                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindVTK.cmake)
00554                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQWT.cmake)
00555                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
00556                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindGUI.cmake)
00557                         ENDIF(GUI_ROOT_DIR)
00558                         """)
00559                         if self.module == "med":
00560                             newlines.append("""
00561                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00562                             IF(WINDOWS)
00563                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
00564                             ENDIF(WINDOWS)
00565                             """)
00566                             pass
00567                         if self.module == "smesh":
00568                             newlines.append("""
00569                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00570                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00571                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00572                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00573                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00574                             """)
00575                             pass
00576                         if self.module == "netgenplugin":
00577                             newlines.append("""
00578                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00579                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00580                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00581                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00582                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00583                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00584                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindNETGEN.cmake)
00585                             """)
00586                             pass
00587                         if self.module == "blsurfplugin":
00588                             newlines.append("""
00589                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00590                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00591                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00592                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00593                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00594                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00595                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindBLSURF.cmake)
00596                             """)
00597                             pass
00598                         if self.module in ["ghs3dplugin", "hexoticplugin"]:
00599                             newlines.append("""
00600                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00601                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00602                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00603                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00604                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00605                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00606                             """)
00607                             pass
00608                         if self.module == "ghs3dprlplugin":
00609                             newlines.append("""
00610                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00611                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00612                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00613                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00614                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00615                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00616                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00617                             """)
00618                             pass
00619                         if self.module == "visu":
00620                             newlines.append("""
00621                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00622                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00623                             """)
00624                             pass
00625                         if self.module == "yacs":
00626                             newlines.append("""
00627                             INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindEXPAT.cmake)
00628                             INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindGRAPHVIZ.cmake)
00629                             """)
00630                             pass
00631                         if self.module == "hxx2salome":
00632                             newlines.append("""
00633                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00634                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00635                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00636                             """)
00637                             pass
00638                         pass
00639                     pass
00640                 pass
00641             # --
00642             newlines.append("""
00643             SET(DOXYGEN_IS_OK 0)
00644             """)
00645             if self.module not in ['med']:
00646                 newlines.append("""
00647                 IF(WINDOWS)
00648                 SET(CPPUNIT_IS_OK 0)
00649                 ENDIF(WINDOWS)
00650                 """)
00651                 pass
00652             # --
00653             if self.module == "kernel":
00654                 newlines.append("""
00655                 SET(WITH_LOCAL 1)
00656                 SET(WITH_BATCH 1)
00657                 SET(CALCIUM_IDL_INT_F77 long)
00658                 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
00659                 SET(LONG_OR_INT int)
00660                 """)
00661             elif self.module == "gui":
00662                 newlines.append("""
00663                 SET(GUI_ENABLE_CORBA ${CORBA_GEN})
00664                 SET(ENABLE_VTKVIEWER ON)
00665                 SET(ENABLE_SALOMEOBJECT ON)
00666                 SET(ENABLE_OCCVIEWER ON)
00667                 SET(ENABLE_GLVIEWER ON)
00668                 SET(ENABLE_PLOT2DVIEWER ON)
00669                 SET(ENABLE_PYCONSOLE ON)
00670                 SET(ENABLE_SUPERVGRAPHVIEWER ON)
00671                 SET(ENABLE_QXGRAPHVIEWER ON)
00672                 """)
00673                 pass
00674             elif self.module == "jobmanager":
00675                 newlines.append("""
00676                 IF(GUI_ROOT_DIR)
00677                 SET(HAS_GUI ON)
00678                 ENDIF(GUI_ROOT_DIR)
00679                 """)
00680                 pass
00681             elif self.module == "geom":
00682                 newlines.append("""
00683                 IF(GUI_ROOT_DIR)
00684                 SET(GEOM_ENABLE_GUI ON)
00685                 ENDIF(GUI_ROOT_DIR)
00686                 """)
00687                 pass
00688             elif self.module == "medfile":
00689                 newlines.append("""
00690                 SET(MED_NUM_MAJEUR 3)
00691                 SET(MED_NUM_MINEUR 0)
00692                 SET(MED_NUM_RELEASE 3)
00693                 SET(LONG_OR_INT int)
00694                 IF(NOT WINDOWS)
00695                 SET(FLIBS -lgfortranbegin -lgfortran)
00696                 ENDIF(NOT WINDOWS)
00697                 """)
00698                 pass
00699             elif self.module == "med":
00700                 newlines.append("""
00701                 IF(KERNEL_ROOT_DIR)
00702                 SET(MED_ENABLE_KERNEL ON)
00703                 IF(NOT WINDOWS)
00704                 SET(MED_ENABLE_SPLITTER ON)
00705                 ENDIF(NOT WINDOWS)
00706                 ENDIF(KERNEL_ROOT_DIR)
00707                 IF(GUI_ROOT_DIR)
00708                 SET(MED_ENABLE_GUI ON)
00709                 ENDIF(GUI_ROOT_DIR)
00710                 """)
00711                 pass
00712             elif self.module == "smesh":
00713                 newlines.append("""
00714                 IF(GUI_ROOT_DIR)
00715                 SET(SMESH_ENABLE_GUI ON)
00716                 ENDIF(GUI_ROOT_DIR)
00717                 """)
00718                 pass
00719             elif self.module == "netgen":
00720                 newlines.append("""
00721                 SET(OCCFLAGS ${CAS_CPPFLAGS})
00722                 SET(OCCLIBS ${CAS_LDPATH})
00723                 SET(OCCLIBS ${OCCLIBS} ${TKernel} ${TKGeomBase} ${TKMath} ${TKG2d} ${TKG3d} ${TKXSBase} ${TKOffset} ${TKFillet} ${TKShHealing})
00724                 SET(OCCLIBS ${OCCLIBS} ${TKMesh} ${TKMeshVS} ${TKTopAlgo} ${TKGeomAlgo} ${TKBool} ${TKPrim} ${TKBO} ${TKIGES} ${TKBRep})
00725                 SET(OCCLIBS ${OCCLIBS} ${TKSTEPBase} ${TKSTEP} ${TKSTL} ${TKSTEPAttr} ${TKSTEP209} ${TKXDESTEP} ${TKXDEIGES} ${TKXCAF} ${TKLCAF} ${FWOSPlugin})
00726                 """)
00727                 pass
00728             elif self.module == "netgenplugin":
00729                 newlines.append("""
00730                 IF(GUI_ROOT_DIR)
00731                 SET(NETGENPLUGIN_ENABLE_GUI ON)
00732                 ENDIF(GUI_ROOT_DIR)
00733                 """)
00734                 pass
00735             elif self.module == "blsurfplugin":
00736                 newlines.append("""
00737                 IF(GUI_ROOT_DIR)
00738                 SET(BLSURFPLUGIN_ENABLE_GUI ON)
00739                 ENDIF(GUI_ROOT_DIR)
00740                 """)
00741                 pass
00742             elif self.module == "ghs3dplugin":
00743                 newlines.append("""
00744                 IF(GUI_ROOT_DIR)
00745                 SET(GHS3DPLUGIN_ENABLE_GUI ON)
00746                 ENDIF(GUI_ROOT_DIR)
00747                 """)
00748                 pass
00749             elif self.module == "hexoticplugin":
00750                 newlines.append("""
00751                 IF(GUI_ROOT_DIR)
00752                 SET(HEXOTICPLUGIN_ENABLE_GUI ON)
00753                 ENDIF(GUI_ROOT_DIR)
00754                 """)
00755                 pass
00756             elif self.module == "ghs3dprlplugin":
00757                 newlines.append("""
00758                 IF(GUI_ROOT_DIR)
00759                 SET(GHS3DPRLPLUGIN_ENABLE_GUI ON)
00760                 ENDIF(GUI_ROOT_DIR)
00761                 """)
00762                 pass
00763             elif self.module == "yacs":
00764                 newlines.append("""
00765                 SET(SALOME_KERNEL ON)
00766                 SET(HAS_GUI ON)
00767                 SET(WITH_QT4 ON)
00768                 """)
00769                 pass
00770             # --
00771             newlines.append("""
00772             set(VERSION 6.3.1)
00773             set(XVERSION 0x060301)
00774             """)
00775             pass
00776         # --
00777         newlines.append("""
00778         SET(VERSION_INFO 0.0.0)
00779         SET(SOVERSION_INFO 0)
00780         SET(SUBDIRS)
00781         SET(AM_CPPFLAGS)
00782         SET(AM_CXXFLAGS)
00783         SET(LDADD)
00784         SET(pythondir lib/python${PYTHON_VERSION}/site-packages)
00785         SET(salomepythondir ${pythondir}/salome)
00786         SET(salomepypkgdir ${salomepythondir}/salome)
00787         """)
00788         if self.module == "netgen":
00789             newlines.append(r'''
00790             SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY -I${CMAKE_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR})
00791             ''')
00792         elif self.module == "kernel":
00793             newlines.append(r'''
00794             SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h)
00795             SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h)
00796             ''')
00797         else:
00798             if self.module not in ["yacs"]:
00799                 newlines.append(r'''
00800                 IF(KERNEL_ROOT_DIR)
00801                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DHAVE_SALOME_CONFIG -I${KERNEL_ROOT_DIR}/include/salome -include SALOMEconfig.h)
00802                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DHAVE_SALOME_CONFIG -I${KERNEL_ROOT_DIR}/include/salome -include SALOMEconfig.h)
00803                 ENDIF(KERNEL_ROOT_DIR)
00804                 ''')
00805                 pass
00806             if self.module == "gui":
00807                 newlines.append(r'''
00808                 IF(KERNEL_ROOT_DIR)
00809                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DWITH_SALOMEDS_OBSERVER)
00810                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DWITH_SALOMEDS_OBSERVER)
00811                 ENDIF(KERNEL_ROOT_DIR)
00812                 ''')
00813                 pass
00814             if self.module in ["smesh", "netgenplugin", "blsurfplugin", "ghs3dplugin", "hexoticplugin"]:
00815                 newlines.append(r'''
00816                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DWITH_SMESH_CANCEL_COMPUTE)
00817                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DWITH_SMESH_CANCEL_COMPUTE)
00818                 ''')
00819                 pass
00820             if self.module == "ghs3dplugin":
00821               # TODO: Auto-detect TetGen-GHS3D version automatically
00822                 newlines.append(r'''
00823                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DGHS3D_VERSION=42)
00824                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DGHS3D_VERSION=42)
00825                 ''')
00826                 pass              
00827             if self.module == "hxx2salome":
00828                 key = "_SRC"
00829                 if self.the_root[-len(key):] != key:
00830                     msg = "Source dir must finished with %s !"%(key)
00831                     raise Exception(msg)
00832                 hxxmodule = self.the_root[:-len(key)]
00833                 from os.path import basename
00834                 hxxmodule = basename(hxxmodule)
00835                 hxxmodule = hxxmodule.lower()
00836                 self.hxxmodule = hxxmodule
00837                 newlines.append(r'''
00838                 SET(HXXCPP_ROOT_DIR $ENV{%sCPP_ROOT_DIR})
00839                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -I${HXXCPP_ROOT_DIR}/include)
00840                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -I${HXXCPP_ROOT_DIR}/include)
00841                 SET(LDADD ${LDADD} -L${HXXCPP_ROOT_DIR}/lib)
00842                 '''%(hxxmodule.upper()))
00843                 pass
00844             pass
00845         # --
00846         return
00847     
00848     def treatLine(self, line, newlines, opened_ifs):
00849         
00850         # --
00851         # Print the comment above the line itself
00852         # --
00853         if line.find('#') >= 0:
00854             fields = line.split('#')
00855             line = fields[0]
00856             comment = '#'.join([''] + fields[1:])
00857             newlines.append(comment)
00858             if len(line) == 0:
00859                 return
00860             pass
00861         
00862         # --
00863         # If the line begins with 'include ', just comment it
00864         # --
00865         if line.find("include ") == 0:
00866             if line.find("include $(top_srcdir)/config/automake.common") == 0:
00867                 for l in [
00868                     "MAINTAINERCLEANFILES = Makefile.in",
00869                     "AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include",
00870                     "AM_FFLAGS=-I$(top_srcdir)/include  -I$(top_builddir)/include",
00871                     "AM_FCFLAGS=-I$(top_srcdir)/include  -I$(top_builddir)/include",
00872                     "AM_CPPFLAGS+=@HDF5_CPPFLAGS@",
00873                     "AM_LDFLAGS=@HDF5_LDFLAGS@",
00874                     ]:
00875                     self.treatLine(l, newlines, opened_ifs)
00876                     pass
00877                 pass
00878             else:
00879                 newlines.append("# " + line)
00880                 pass
00881             return
00882         
00883         # --
00884         # If the line begins with '-include', just comment it
00885         # --
00886         if line.find("-include") == 0:
00887             newlines.append("# " + line)
00888             return
00889         
00890         # --
00891         # If the line is a definition of a make rule, just comment it
00892         # --
00893         if line.count(':') == 1:
00894             newlines.append("# " + line)
00895             return
00896         
00897         # --
00898         # A particuliar case where there are two ":" on the same line
00899         # --
00900         if line.find('install-exec-local:') == 0:
00901             newlines.append("# " + line)
00902             return
00903         
00904         # --
00905         # If the line begin by a tabulation, consider it's a makefile command and comment it
00906         # --
00907         if line.find("\t") == 0:
00908             newlines.append("# " + line)
00909             return
00910         
00911         # --
00912         # --
00913         key = "-version-info"
00914         if line.find(key) >= 0:
00915             # --
00916             before = line.split(key)[0]
00917             after = line[len(before)+len(key):]
00918             sep = after[0]
00919             after = after[1:]
00920             version_info = after.split()[0]
00921             line = line.replace(key+sep+version_info, "")
00922             # --
00923             version_info = version_info.replace(':', '.')
00924             soversion_info = version_info.split('.')[0]
00925             newlines.append("SET(VERSION_INFO " + version_info + ")")
00926             newlines.append("SET(SOVERSION_INFO " + soversion_info + ")")
00927             # --
00928             pass
00929         
00930         # --
00931         # Replace the $(TOTO) by ${TOTO}
00932         # Replace the @TOTO@  by ${TOTO}
00933         # --
00934         line = p_dollar.sub(r"${\1}", line)
00935         line = p_arobas.sub(r"${\1}", line)
00936         
00937         # --
00938         line = line.replace(r"${top_builddir}", r"${CMAKE_BINARY_DIR}")
00939         line = line.replace(r"${top_srcdir}", r"${CMAKE_SOURCE_DIR}")
00940         line = line.replace(r"${srcdir}", r"${CMAKE_CURRENT_SOURCE_DIR}")
00941         line = line.replace(r"${builddir}", r"${CMAKE_CURRENT_BINARY_DIR}")
00942         line = line.replace(r"${datadir}", r"${CMAKE_INSTALL_PREFIX}/share")
00943         
00944         # --
00945         # Check if the line is a 'if' condition
00946         # If yes, replace it by a cmake grammar
00947         # --
00948         match = p_if.match(line)
00949         if match:
00950             theif = match.group("val")
00951             if theif[0] == "!":
00952                 theif = "NOT " + theif[1:]
00953                 pass
00954             line = p_if.sub(r"IF(%s)"%(theif), line)
00955             opened_ifs.append(theif)
00956             newlines.append(line)
00957             return
00958         
00959         # --
00960         # Check if the line is a 'else' condition
00961         # If yes, replace it by a cmake grammar
00962         # --
00963         match = p_else.match(line)
00964         if match:
00965             line = "ELSE(%s)"%(opened_ifs[-1])
00966             newlines.append(line)
00967             return
00968         
00969         # --
00970         # Check if the line is a 'endif' condition
00971         # If yes, replace it by a cmake grammar
00972         # --
00973         match = p_endif.match(line)
00974         if match:
00975             line = "ENDIF(%s)"%(opened_ifs[-1])
00976             opened_ifs[-1:] = []
00977             newlines.append(line)
00978             return
00979         
00980         # --
00981         # Check if the line is an attribution '=' or '+='
00982         # --
00983         match = p_attribution.match(line)
00984         if match:
00985             self.treatAttribution(match, newlines)
00986             return
00987         
00988         # --
00989         newlines.append(line)
00990         
00991         # --
00992         return
00993     
00994     def treatAttribution(self, match, newlines):
00995         
00996         spaces = match.group("spaces")
00997         key = match.group("key")
00998         method = match.group("method")
00999         value = match.group("value")
01000         # print [spaces, key, method, value]
01001         
01002         # --
01003         # Open cmake SET command
01004         # --
01005         newlines.append(spaces + "SET(" + key)
01006         
01007         # --
01008         # If method is '+=', put the previous definition as first value
01009         # --
01010         if method == "+=":
01011             newlines.append("%s    ${%s}"%(spaces, key))
01012             pass
01013         
01014         # --
01015         fields = value.split()
01016         for i in range(len(fields)):
01017             newlines.append("%s    %s"%(spaces, fields[i]))
01018             pass
01019         
01020         # --
01021         if method == "+=":
01022             # --
01023             # The try: except KeyError is here if the +=
01024             # is an error which occurs in salome ...
01025             # --
01026             try:
01027                 self.__thedict__[key] += fields[:]
01028             except KeyError:
01029                 self.__thedict__[key] = fields[:]
01030                 pass
01031             pass
01032         else:
01033             self.__thedict__[key]  = fields[:]
01034             pass
01035         
01036         # --
01037         # Close cmake SET command
01038         # --
01039         
01040         newlines.append("%s)"%(spaces))
01041         
01042         return
01043     
01044     def finalize(self, newlines):
01045       
01046         # --
01047         # Convert the .in files in build dir
01048         # --
01049 
01050         import operator
01051         mod = self.module
01052         if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'):
01053             newlines.append(r'''
01054             SET(top_builddir
01055                 ${CMAKE_BINARY_DIR}
01056             )
01057             SET(top_srcdir 
01058                 ${CMAKE_SOURCE_DIR}
01059             )
01060             SET(srcdir 
01061                 ${CMAKE_CURRENT_SOURCE_DIR}
01062             )
01063             SET(builddir 
01064                 ${CMAKE_CURRENT_BINARY_DIR}
01065             )
01066             SET(datadir
01067                 ${CMAKE_INSTALL_PREFIX}/share
01068             )
01069             SET(docdir 
01070                 ${datadir}/doc/salome
01071             )
01072             ''')
01073             self.files.append("static/header.html.in")
01074         elif self.root[-len(mod):] == mod.upper() and operator.contains(self.root, 'doc') or mod in ['kernel', 'gui', 'geom', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui':
01075             newlines.append(r'''
01076             SET(top_builddir
01077                 ${CMAKE_BINARY_DIR}
01078             )
01079             SET(top_srcdir 
01080                 ${CMAKE_SOURCE_DIR}
01081             )
01082             SET(srcdir 
01083                 ${CMAKE_CURRENT_SOURCE_DIR}
01084             )
01085             SET(builddir 
01086                 ${CMAKE_CURRENT_BINARY_DIR}
01087             )
01088             SET(datadir
01089                 ${CMAKE_INSTALL_PREFIX}/share
01090             )
01091             SET(docdir 
01092                 ${datadir}/doc/salome
01093             )
01094             ''')
01095             self.files.append("static/header.html.in")
01096                         
01097             if mod in ['geom', 'smesh', 'visu'] and self.root[-len(mod):] == mod.upper():
01098               self.files.append("static/header_py.html.in")
01099      
01100         if self.module == "yacs":
01101             key = "salomegui"
01102             if self.root[-len(key):] == key:
01103                 self.files.append("resources/YACSCatalog.xml.in")
01104                 pass
01105             pass
01106         for f in self.files:
01107             if f[-3:] == ".in":
01108                 if self.module == 'yacs' and f == "Doxyfile.in":
01109                     continue
01110                 if f == "sstream.in":
01111                     continue
01112                 if f in ["runContainer.in", "stopContainer.in"]:
01113                     if self.module == "med":
01114                         if self.root[-3:] == "csh":
01115                             continue
01116                         pass
01117                     pass
01118                 if f == "SALOMEconfig.ref.in":
01119                     out = "SALOMEconfig.h"
01120                 else:
01121                     out = f[:-3]
01122                     pass
01123                 newlines.append(r'''
01124                 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/%s)
01125                 '''%(f))
01126                 newlines.append(r'''
01127                 SET(output ${CMAKE_CURRENT_BINARY_DIR}/%s)
01128                 '''%(out))
01129                 newlines.append(r'''
01130                 MESSAGE(STATUS "Creation of ${output}")
01131                 CONFIGURE_FILE(${input} ${output})
01132                 ''')
01133                 pass
01134             pass
01135 
01136         # --
01137         # add commands for generating of user's documentation
01138         # --
01139   
01140         upmod = self.module.upper()
01141         doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/%s"%(upmod)
01142         doc_tui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s"%(upmod)
01143         doc_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome"
01144         head_source = "${CMAKE_CURRENT_SOURCE_DIR}/images/head.png"
01145         if mod == 'kernel':
01146             copytree_src = "${CMAKE_SOURCE_DIR}/salome_adm/cmake_files"
01147         else:
01148             copytree_src = "$ENV{KERNEL_ROOT_DIR}/salome_adm/cmake_files"
01149         str = "import re \nimport sys \noutfile = open(sys.argv[1], 'wb') \nfor line in open(sys.argv[2], 'rb').readlines():"
01150         str += "\n    if re.match('class '+sys.argv[3]+'DC', line): \n        continue \n    line = re.sub(r'^\\\\s+\#', '#', line) \n    line = re.sub(r'^\\\\s+def', 'def', line) \n    line = re.sub(sys.argv[3]+'DC', sys.argv[3], line)"
01151         str += "\n    outfile.write(line) \noutfile.close()"
01152 
01153         if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'):
01154             if mod == 'med':
01155                 doc_source = "${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html"
01156                 input = "Doxyfile_med_user"
01157             else:
01158                 doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01159                 input = ""
01160             newlines.append("""\t    ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s
01161             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')"
01162             VERBATIM 
01163             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01164             )"""%(input, copytree_src, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination))
01165                 
01166         if mod in ['geom', 'smesh', 'visu'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'):
01167             ign = r"""'tempfile', '*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'"""
01168             if mod in ['geom', 'smesh']:
01169                 if mod == 'geom':
01170                     tmp = 'geompy'
01171                     input = "COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_tui \n\t\t"
01172                 else:
01173                     tmp =  'smesh' 
01174                     input = ''
01175                 newlines.append(r"""
01176                 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s")
01177                 ADD_CUSTOM_TARGET(usr_docs ${PYTHON_EXECUTABLE} tempfile %s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
01178                 %sCOMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py
01179                 COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01180                 COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''%s.py''')"
01181                 COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''', r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''', r'''%s''')"
01182                 VERBATIM 
01183                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01184                 )"""%(str, tmp, upmod, tmp, tmp, input, tmp, copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
01185             else:
01186                 newlines.append("""\t    ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} doxyfile_idl
01187                 COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01188                 COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''',True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')"
01189                 VERBATIM 
01190                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01191                 )"""%(copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
01192 
01193   # --
01194   # add commands for generating of developer's documentation
01195   # --
01196   
01197         upmod = self.module.upper()
01198         if mod in ['kernel', 'gui', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui':
01199             if mod == 'kernel':
01200                 tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u
01201             COMMAND ${DOXYGEN_EXECUTABLE}
01202             COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_CURRENT_BINARY_DIR}/doxyfile.bak''')"  """
01203                 tmp1=""
01204             else: 
01205                 tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE}"""
01206                 if mod == 'visu':
01207                     tmp1= r"""\n           COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/visuscreen.png''', r'''%s''')" """%(doc_tui_destination)
01208                 elif mod == 'smesh':
01209                     extra_srcdir = "${CMAKE_CURRENT_SOURCE_DIR}/extra"
01210                     tmp1= """\n            COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/smeshscreen.png''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.pdf''', r'''%s'''); copy(r'''%s/PluginMeshers.html''', r'''%s''')" 
01211             COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''%s/AddNetgenInSalome2.ps''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.sxw''', r'''%s''')" """%(doc_tui_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination,extra_srcdir,doc_destination)
01212                 else:
01213                     tmp1=""
01214             doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01215             newlines.append(tmp + """
01216             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """
01217             VERBATIM 
01218             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01219             )""")
01220         if mod == 'geom' and self.root[-len('tui'):] == 'tui':
01221             tmp = 'geompy'
01222             doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01223             newlines.append(r"""
01224             FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s")
01225             ADD_CUSTOM_TARGET(dev_docs ${PYTHON_EXECUTABLE} tempfile ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
01226             COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01227             COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py''')"
01228             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/geomscreen.png''', r'''%s''')"
01229             VERBATIM 
01230             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01231             )"""%(str, upmod, tmp, upmod, tmp, tmp, upmod, tmp, copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination, doc_tui_destination))
01232 
01233         # --
01234         # convert the SUBDIRS in cmake grammar
01235         # --
01236         if 1: # self.__thedict__.has_key("SUBDIRS"):
01237             newlines.append(r'''
01238             FOREACH(dir ${SUBDIRS})
01239             IF(NOT dir STREQUAL .)
01240             ADD_SUBDIRECTORY(${dir})
01241             ENDIF(NOT dir STREQUAL .)
01242             ENDFOREACH(dir ${SUBDIRS})
01243             ''')
01244             pass
01245         
01246         # --
01247         # --
01248         for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES"]:
01249             if self.__thedict__.has_key(key):
01250                 self.addLibTarget(key, newlines)
01251                 pass
01252             pass
01253         
01254         # --
01255         # --
01256         for key in ["bin_PROGRAMS", "check_PROGRAMS"]:
01257             if self.__thedict__.has_key(key):
01258                 self.addBinTarget(key, newlines)
01259                 pass
01260             pass
01261         
01262         # --
01263         # --
01264         if self.__thedict__.has_key("BASEIDL_FILES"):
01265             if not self.__thedict__.has_key("IDL_FILES"):
01266                 self.__thedict__["IDL_FILES"] = self.__thedict__["BASEIDL_FILES"]
01267                 newlines.append('''
01268                 SET(IDL_FILES ${BASEIDL_FILES})
01269                 ''')
01270                 pass
01271             pass
01272         
01273         # --
01274         # --
01275         
01276         key = "IDL_FILES"
01277         if self.__thedict__.has_key(key):
01278             if self.module == "kernel":
01279                 newlines.append('''
01280                 SET(IDL_FILES ${IDL_FILES} Calcium_Ports.idl)
01281                 ''')
01282                 pass
01283             newlines.append('''
01284             FOREACH(input ${IDL_FILES})
01285             STRING(REGEX REPLACE ".idl" "" base ${input})
01286             SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc)
01287             SET(outputs ${src})
01288             SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc)
01289             SET(outputs ${outputs} ${dynsrc})
01290             SET(inc ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
01291             SET(outputs ${outputs} ${inc})
01292             IF(input STREQUAL Calcium_Ports.idl)
01293             SET(input ${CMAKE_CURRENT_BINARY_DIR}/${input})
01294             ELSE(input STREQUAL Calcium_Ports.idl)
01295             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01296             ENDIF(input STREQUAL Calcium_Ports.idl)
01297             SET(flags ${IDLCXXFLAGS} ${OMNIORB_IDLCXXFLAGS})
01298             STRING(REGEX MATCH "-bcxx" ISBCXX ${flags})
01299             IF(NOT ISBCXX)
01300             SET(flags -bcxx ${flags})
01301             ENDIF(NOT ISBCXX)
01302             ADD_CUSTOM_COMMAND(
01303             OUTPUT ${outputs}
01304             COMMAND ${OMNIORB_IDL} ${flags} ${input}
01305             MAIN_DEPENDENCY ${input}
01306             )
01307             ''')
01308             newlines.append('''
01309             install(FILES ${input} DESTINATION idl/salome)
01310             ''')
01311             if self.module not in ["pyhello"]:
01312                 newlines.append('''
01313                 SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
01314                 install(FILES ${IDL_HEADER} DESTINATION include/salome)
01315                 ''')
01316                 pass
01317             newlines.append('''
01318             INSTALL(CODE "SET(IDL_FILE ${input})")
01319             INSTALL(CODE "SET(DIR ${salomepythondir})")
01320             IF(WINDOWS)
01321             INSTALL(CODE "SET(DIR bin/salome)")
01322             ENDIF(WINDOWS)
01323             INSTALL(CODE "SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})")
01324             INSTALL(CODE "SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL_PYTHON})")
01325             # --
01326             SET(flags)
01327             FOREACH(f ${IDLPYFLAGS})
01328             SET(flags "${flags} ${f}")
01329             ENDFOREACH(f ${IDLPYFLAGS})
01330             STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags})
01331             IF(NOT ISBPYTHON)
01332             SET(flags "-bpython ${flags}")
01333             ENDIF(NOT ISBPYTHON)
01334             SET(IDLPYFLAGS ${flags})
01335             STRING(REPLACE "\\\\" "/" IDLPYFLAGS ${IDLPYFLAGS})
01336             INSTALL(CODE "SET(IDLPYFLAGS ${IDLPYFLAGS})")
01337             # --
01338             ''')
01339             if self.module == "kernel":
01340                 newlines.append('''
01341                 INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
01342                 ''')
01343             else:
01344                 newlines.append('''
01345                 STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
01346                 INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
01347                 ''')
01348                 pass
01349             newlines.append('''
01350             ENDFOREACH(input ${IDL_FILES})
01351             ''')
01352             pass
01353         
01354         # --
01355         # --
01356         for key in ["SWIG_SRC", "SWIGSOURCES", "SWIG_DEF"]:
01357             if self.__thedict__.has_key(key):
01358                 newlines.append('''
01359                 SET(SWIG_SOURCES ${%s})
01360                 '''%(key))
01361                 self.__thedict__["SWIG_SOURCES"] = self.__thedict__[key]
01362                 pass
01363             pass
01364         
01365         # --
01366         # --
01367         if self.__thedict__.has_key("SWIG_SOURCES"):
01368             newlines.append('''
01369             IF(SWIG_SOURCES MATCHES ";")
01370             STRING(REGEX REPLACE ";.*" "" SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
01371             ELSE(SWIG_SOURCES MATCHES ";")
01372             SET(SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
01373             ENDIF(SWIG_SOURCES MATCHES ";")
01374             SET(flags)
01375             FOREACH(f ${SWIG_FLAGS} ${MY_SWIG_FLAGS})
01376             SET(test ON)
01377             IF(flags)
01378             LIST(FIND flags ${f} index)
01379             IF(NOT index EQUAL -1)
01380             SET(test OFF)
01381             ENDIF(NOT index EQUAL -1)
01382             ENDIF(flags)
01383             IF(test)
01384             SET(flags ${flags} ${f})
01385             ENDIF(test)
01386             ENDFOREACH(f ${SWIG_FLAGS} ${MY_SWIG_FLAGS})
01387             ADD_CUSTOM_COMMAND(
01388             OUTPUT ${build_srcs}
01389             COMMAND ${SWIG_EXECUTABLE} ${flags} -o ${build_srcs} ${CMAKE_CURRENT_SOURCE_DIR}/${SWIG_SOURCES_FIRST}
01390             MAIN_DEPENDENCY ${SWIG_SOURCES}
01391             )
01392             ''')
01393             pass
01394         
01395         # --
01396         # --
01397         if self.__thedict__.has_key("BUILT_SOURCES"):
01398             newlines.append('''
01399             FOREACH(f ${BUILT_SOURCES})
01400             IF(f MATCHES "WRAP.cxx$")
01401             # STRING(REGEX REPLACE "WRAP.cxx" "WRAP.h" inc ${f})
01402             STRING(REGEX REPLACE "WRAP.cxx" ".i" input ${f})
01403             ADD_CUSTOM_COMMAND(
01404             OUTPUT ${f} # ${inc}
01405             COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${SWIG_PYTHON_INCLUDES} ${MYSWIG_FLAGS} -o ${f} ${CMAKE_CURRENT_SOURCE_DIR}/${input}
01406             MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${input}
01407             )
01408             ENDIF(f MATCHES "WRAP.cxx$")
01409             ENDFOREACH(f ${BUILT_SOURCES})
01410             ''')
01411             pass
01412 
01413         # --
01414         # --
01415         key = "MOC_FILES"
01416         if self.__thedict__.has_key(key):
01417             newlines.append('''
01418             FOREACH(output ${MOC_FILES})
01419             ''')
01420             if self.module in ["jobmanager", "yacs"]:
01421                 newlines.append('''
01422                 STRING(REGEX REPLACE _moc.cxx .hxx input ${output})
01423                 ''')
01424             else:
01425                 newlines.append('''
01426                 STRING(REGEX REPLACE _moc.cxx .h input ${output})
01427                 ''')
01428                 pass
01429             newlines.append('''
01430             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01431             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01432             ADD_CUSTOM_COMMAND(
01433             OUTPUT ${output}
01434             COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input} -o ${output}
01435             MAIN_DEPENDENCY ${input}
01436             )
01437             ENDFOREACH(output ${MOC_FILES})
01438             ''')
01439             pass
01440         
01441         # --
01442         # --
01443         key = "UIC_FILES"
01444         if self.__thedict__.has_key(key):
01445             newlines.append('''
01446             FOREACH(output ${UIC_FILES})
01447             STRING(REPLACE "ui_" "" input ${output})
01448             STRING(REPLACE ".h" ".ui" input ${input})
01449             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01450             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01451             ADD_CUSTOM_COMMAND(
01452             OUTPUT ${output}
01453             COMMAND ${QT_UIC_EXECUTABLE} -o ${output} ${input}
01454             MAIN_DEPENDENCY ${input}
01455             )
01456             ENDFOREACH(output ${UIC_FILES})
01457             ''')
01458             pass
01459         
01460         # --
01461         # --
01462         key = "QRC_FILES"
01463         if self.__thedict__.has_key(key):
01464             newlines.append('''
01465             FOREACH(output ${QRC_FILES})
01466             STRING(REGEX REPLACE "qrc_" "" input ${output})
01467             STRING(REGEX REPLACE ".cxx" ".qrc" input ${input})
01468             STRING(REGEX REPLACE ".qrc" "" name ${input})
01469             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01470             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01471             ADD_CUSTOM_COMMAND(
01472             OUTPUT ${output}
01473             COMMAND ${QT_RCC_EXECUTABLE} ${input} -o ${output} -name ${name}
01474             MAIN_DEPENDENCY ${input}
01475             )
01476             ENDFOREACH(output ${QRC_FILES})
01477             ''')
01478             pass
01479         
01480         # --
01481         # --
01482         key = "SIP_FILES"
01483         if self.__thedict__.has_key(key):
01484             newlines.append('''
01485             FOREACH(input ${SIP_FILES})
01486             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01487             SET(output)
01488             FOREACH(out ${SIP_SRC})
01489             SET(output ${output} ${CMAKE_CURRENT_BINARY_DIR}/${out})
01490             ENDFOREACH(out ${SIP_SRC})
01491             ADD_CUSTOM_COMMAND(
01492             OUTPUT ${output}
01493             COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${input}
01494             MAIN_DEPENDENCY ${input}
01495             )
01496             ENDFOREACH(input ${SIP_FILES})
01497             ''')
01498             pass
01499 
01500         # --
01501         # For make check
01502         # --
01503         for key in ["TESTS"]:
01504             if self.__thedict__.has_key(key):
01505                 newlines.append('''
01506                 SET(UNIT_TEST_PROG ${%s})
01507                 '''%(key))
01508                 self.__thedict__["UNIT_TEST_PROG"] = self.__thedict__[key]
01509                 pass
01510             pass
01511         key = "UNIT_TEST_PROG"
01512         if self.__thedict__.has_key(key):
01513             newlines.append('''
01514             FOREACH(input ${UNIT_TEST_PROG})
01515             GET_FILENAME_COMPONENT(ext ${input} EXT)
01516             IF(ext STREQUAL .py)
01517             SET(test ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01518             ELSE(ext STREQUAL .py)
01519             IF(WINDOWS)
01520             SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe.exe)
01521             ELSE()
01522             SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe)
01523             ENDIF()
01524             ENDIF(ext STREQUAL .py)
01525             ADD_TEST(${input} ${test})
01526             SET(fail_regex "KO")
01527             SET_PROPERTY(TEST ${input} PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}")
01528             # IF(NOT WINDOWS)
01529             # ADD_TEST(${input}_valgrind valgrind ${test})
01530             # SET_PROPERTY(TEST ${input}_valgrind PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}")
01531             # SET_PROPERTY(TEST ${input}_valgrind PROPERTY PASS_REGULAR_EXPRESSION "no leaks are possible")
01532             # ENDIF()
01533             ENDFOREACH(input ${UNIT_TEST_PROG})
01534             ''')
01535             pass
01536         
01537         # --
01538         # Treat the install targets
01539         # --
01540         resdir = self.module
01541         if resdir == "hxx2salome":
01542             resdir = self.hxxmodule
01543             pass
01544         d = {
01545             "salomeadmux_DATA"                 :  "salome_adm/unix",
01546             "dist_salomeadmux_DATA"            :  "salome_adm/unix",
01547             "dist_salome_cmake_DATA"           :  "salome_adm/cmake_files",
01548             "dist_salomem4_DATA"               :  "salome_adm/unix/config_files",
01549             "dist_salome4depr_DATA"            :  "salome_adm/unix/config_files/DEPRECATED",
01550             "dist_admlocalm4_DATA"             :  "adm_local/unix/config_files",
01551             "dist_admlocal_cmake_DATA"         :  "adm_local/cmake_files",
01552             "salomeinclude_DATA"               :  "include/salome",
01553             "salomeinclude_HEADERS"            :  "include/salome",
01554             "nodist_salomeinclude_HEADERS"     :  "include/salome",
01555             "dist_salomeres_DATA"              :  "share/salome/resources/%s"%(resdir),
01556             "nodist_salomeres_DATA"            :  "share/salome/resources/%s"%(resdir),
01557             "nodist_salomeres_SCRIPTS"         :  "share/salome/resources/%s"%(resdir),
01558             "dist_salomescript_SCRIPTS"        :  "bin/salome",
01559             "dist_salomescript_DATA"           :  "bin/salome",
01560             "dist_salomescript_PYTHON"         :  "bin/salome",
01561             "nodist_salomescript_DATA"         :  "bin/salome",
01562             "salomepython_PYTHON"              :  "${salomepythondir}",
01563             "nodist_salomepython_PYTHON"       :  "${salomepythondir}",
01564             "dist_salomepython_DATA"           :  "${salomepythondir}",
01565             "sharedpkgpython_PYTHON"           :  "${salomepythondir}/shared_modules",
01566             "salomepypkg_PYTHON"               :  "${salomepypkgdir}",
01567             "mypkgpython_PYTHON"               :  "${mypkgpythondir}",
01568             }
01569         if self.module == "jobmanager":
01570             d["bin_SCRIPTS"] = "bin"
01571             pass
01572         if self.module == "medfile":
01573             d = {
01574                 "include_HEADERS"        :  "include",
01575                 "nodist_include_HEADERS" :  "include",
01576                 "bin_SCRIPTS"            :  "bin",
01577                 "doc_DATA"               :  "${docdir}",
01578                 }
01579             pass
01580         if self.module == "netgen":
01581             d = {
01582                 "include_HEADERS"        :  "include",
01583                 "noinst_HEADERS"         :  "share/netgen/include",
01584                 "dist_pkgdata_DATA"      :  "share/netgen",
01585                 "dist_doc_DATA"          :  "share/doc/netgen",
01586                 }
01587             pass
01588         for key, value in d.items():
01589             if self.__thedict__.has_key(key):
01590                 self.addInstallTarget(key, value, newlines)
01591                 pass
01592             pass
01593         
01594         # --
01595         return
01596     
01597     def setLibAdd(self, key, newlines):
01598         # --
01599         newlines.append(r'''
01600         SET(libadd)
01601         ''')
01602         # --
01603         newlines.append(r'''
01604         IF(WINDOWS)
01605         SET(targets)
01606         SET(targets ${targets} MEFISTO2D)
01607         FOREACH(target ${targets})
01608         IF(name STREQUAL ${target})
01609         SET(dir $ENV{F2CHOME})
01610         STRING(REPLACE "\\\\" "/" dir ${dir})
01611         SET(libadd ${libadd} ${dir}/LIBF77.lib)
01612         SET(libadd ${libadd} ${dir}/LIBI77.lib)
01613         ENDIF(name STREQUAL ${target})
01614         ENDFOREACH(target ${targets})
01615         ENDIF(WINDOWS)
01616         ''')
01617         # --
01618         newlines.append(r'''
01619         SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${LDADD} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS})
01620         FOREACH(lib SALOMEBasics SalomeBatch)
01621         IF(name STREQUAL lib)
01622         SET(libs ${libs} ${PTHREAD_LIBS})
01623         ENDIF(name STREQUAL lib)
01624         ENDFOREACH(lib SALOMEBasics SalomeBatch)
01625         ''')
01626         # --
01627         newlines.append(r'''
01628         FOREACH(lib ${libs})
01629         GET_FILENAME_COMPONENT(ext ${lib} EXT)
01630         IF(ext STREQUAL .la)
01631         GET_FILENAME_COMPONENT(lib ${lib} NAME_WE)
01632         STRING(REGEX REPLACE "^lib" "" lib ${lib})
01633         ENDIF(ext STREQUAL .la)
01634         SET(vars)
01635         SET(vars ${vars} -no-undefined)
01636         SET(vars ${vars} -lvtkWidgets)
01637         IF(WINDOWS)
01638         SET(vars ${vars} -module)
01639         SET(vars ${vars} -Wl,-E)
01640         SET(vars ${vars} -Xlinker)
01641         SET(vars ${vars} -export-dynamic)
01642         SET(vars ${vars} -lm)
01643         SET(vars ${vars} -lboost_thread)
01644         SET(vars ${vars} -lboost_signals)
01645         SET(vars ${vars} -pthread -lpthread -ldl)
01646         ENDIF(WINDOWS)
01647         FOREACH(v ${vars})
01648         IF(lib STREQUAL v)
01649         SET(lib)
01650         ENDIF(lib STREQUAL v)
01651         ENDFOREACH(v ${vars})
01652         SET(test OFF)
01653         IF(lib)
01654         STRING(REGEX MATCH "^-lQt" test ${lib})
01655         ENDIF(lib)
01656         IF(NOT test)
01657         SET(libadd ${libadd} ${lib})
01658         ENDIF(NOT test)
01659         ENDFOREACH(lib ${libs})
01660         TARGET_LINK_LIBRARIES(${name} ${libadd})
01661         ''')
01662         # --
01663         newlines.append(r'''
01664         IF(WINDOWS)
01665         SET(targets)
01666         SET(targets ${targets} MEFISTO2D)
01667         FOREACH(target ${targets})
01668         IF(name STREQUAL ${target})
01669         IF(CMAKE_BUILD_TYPE STREQUAL Debug)
01670         SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
01671         ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
01672         ENDIF(name STREQUAL ${target})
01673         ENDFOREACH(target ${targets})
01674         ENDIF(WINDOWS)
01675         ''')
01676         # --
01677         return
01678     
01679     def setCompilationFlags(self, key, newlines):
01680         newlines.append(r'''
01681         SET(var)
01682         IF(WINDOWS)
01683         SET(targets)
01684         SET(targets ${targets} SalomeIDLKernel)
01685         SET(targets ${targets} SalomeDS)
01686         SET(targets ${targets} SALOMEDSTest)
01687         SET(targets ${targets} SALOMEDS_Client_exe)
01688         SET(targets ${targets} SalomeIDLGEOM)
01689         SET(targets ${targets} GEOMEngine)
01690         SET(targets ${targets} MEDEngine)
01691         SET(targets ${targets} SMESHEngine)
01692         SET(targets ${targets} SMESH)
01693         SET(targets ${targets} StdMeshersEngine)
01694         SET(targets ${targets} VISUEngineImpl)
01695         FOREACH(target ${targets})
01696         IF(name STREQUAL ${target})
01697         SET(var ${var} -DNOGDI)
01698         ENDIF(name STREQUAL ${target})
01699         ENDFOREACH(target ${targets})
01700         ENDIF(WINDOWS)
01701         ''')
01702         # --
01703         if self.module in ["medfile", "yacs"]:
01704             newlines.append(r'''
01705             IF(WINDOWS)
01706             SET(var ${var} -DNOGDI)
01707             ENDIF(WINDOWS)
01708             ''')
01709             pass
01710         # --
01711         newlines.append(r'''
01712         IF(WINDOWS)
01713         SET(targets)
01714         SET(targets ${targets} MEFISTO2D)
01715         FOREACH(target ${targets})
01716         IF(name STREQUAL ${target})
01717         SET(dir $ENV{F2CHOME})
01718         STRING(REPLACE "\\\\" "/" dir ${dir})
01719         SET(var ${var} -I${dir})
01720         SET(var ${var} -DF2C_BUILD)
01721         ENDIF(name STREQUAL ${target})
01722         ENDFOREACH(target ${targets})
01723         ENDIF(WINDOWS)
01724         ''')
01725         # --
01726         if self.module in ["geom", "med"]:
01727             newlines.append(r'''
01728             SET(var ${var} -I${CMAKE_CURRENT_SOURCE_DIR})
01729             SET(var ${var} -I${CMAKE_CURRENT_BINARY_DIR})
01730             ''')
01731             pass
01732         newlines.append(r'''
01733         SET(var ${var} ${AM_CPPFLAGS})
01734         SET(var ${var} ${AM_CXXFLAGS})
01735         ''')
01736         # --
01737         newlines.append(r'''
01738         IF(type STREQUAL STATIC)
01739         SET(var ${var} -fPIC)
01740         ENDIF(type STREQUAL STATIC)
01741         ''')
01742         # --
01743         if self.module == "yacs":
01744             newlines.append(r'''
01745             SET(var ${var} -DYACS_PTHREAD)
01746             SET(var ${var} -DCMAKE_BUILD)
01747             SET(var ${var} -DSALOME_KERNEL)
01748             SET(var ${var} -DDSC_PORTS)
01749             SET(var ${var} -DOMNIORB)
01750             ''')
01751             pass
01752         newlines.append(r'''
01753   SET(var ${var} ${PLATFORM_CPPFLAGS})
01754   SET(var ${var} ${PTHREAD_CFLAGS})
01755   SET(var ${var} ${${amname}_CPPFLAGS})
01756   SET(var ${var} ${${amname}_CXXFLAGS})
01757   SET(var ${var} ${${amname}_CFLAGS})
01758         SET(vars)
01759         IF(WINDOWS)
01760         SET(vars ${vars} -include SALOMEconfig.h)
01761         SET(vars ${vars} -ftemplate-depth-32)
01762         SET(vars ${vars} -fPIC)
01763         SET(vars ${vars} -g)
01764         ENDIF(WINDOWS)
01765         SET(flags)
01766         FOREACH(f ${var})
01767         FOREACH(v ${vars})
01768         IF(f STREQUAL v)
01769         SET(f)
01770         ENDIF(f STREQUAL v)
01771         ENDFOREACH(v ${vars})
01772         IF(f)
01773         string(REGEX MATCH "^-I" test_include ${f})
01774         if(test_include)
01775         string(REGEX REPLACE "^-I" "" include_dir ${f})
01776         if(include_dir)
01777         if(include_dir STREQUAL /usr/include)
01778         else(include_dir STREQUAL /usr/include)
01779         string(REGEX MATCH "^\\." test_dot ${include_dir})
01780         if(test_dot)
01781         set(include_dir ${CMAKE_CURRENT_BINARY_DIR}/${include_dir})
01782         endif(test_dot)
01783         include_directories(${include_dir})
01784         endif(include_dir STREQUAL /usr/include)
01785         endif(include_dir)
01786         else(test_include)
01787         SET(flags "${flags} ${f}")
01788         endif(test_include)
01789         ENDIF(f)
01790         ENDFOREACH(f ${var})
01791         SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}")
01792         ''')
01793         return
01794     
01795     def addLibTarget(self, key, newlines):
01796         newlines.append(r'''
01797         FOREACH(amname ${%s})
01798         '''%(key))
01799         # --
01800         # Replace .la by _la ...
01801         # --
01802         newlines.append(r'''
01803         STRING(REPLACE .la _la amname ${amname})
01804         ''')
01805         # --
01806         # Remove the _la for the cmake name
01807         # --
01808         newlines.append(r'''
01809         STRING(LENGTH ${amname} len)
01810         MATH(EXPR newlen "${len}-3")
01811         STRING(SUBSTRING ${amname} 0 ${newlen} name)
01812         ''')
01813         # --
01814         # Does the target begins with lib ??
01815         # If yes, remove lib at beginning for cmake name
01816         # --
01817         newlines.append(r'''
01818         STRING(REGEX MATCH "^lib" BEGIN_WITH_lib ${name})
01819         IF(BEGIN_WITH_lib)
01820         STRING(LENGTH ${name} len)
01821         MATH(EXPR newlen "${len}-3")
01822         STRING(SUBSTRING ${name} 3 ${newlen} name)
01823         ENDIF(BEGIN_WITH_lib)
01824         ''')
01825         # --
01826         # Does the target is an idl library
01827         # --
01828         newlines.append(r'''
01829         STRING(REGEX MATCH "IDL" ISIDL ${name})
01830         ''')
01831         # --
01832         # Set the type of the library
01833         # --
01834         newlines.append(r'''
01835         IF(ISIDL)
01836         IF(WINDOWS)
01837         SET(type STATIC)
01838         ELSE(WINDOWS)
01839         SET(type SHARED)
01840         ENDIF(WINDOWS)
01841         ELSE(ISIDL)
01842         SET(type SHARED)
01843         ENDIF(ISIDL)
01844         ''')
01845         if key == "noinst_LTLIBRARIES":
01846             newlines.append(r'''
01847             IF(WINDOWS)
01848             SET(type STATIC)
01849             ELSE(WINDOWS)
01850             SET(type STATIC)
01851             ENDIF(WINDOWS)
01852             ''')
01853             pass
01854         # --
01855         # Set sources for the library
01856         # --
01857         newlines.append(r'''
01858         SET(srcs)
01859         FOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
01860         GET_FILENAME_COMPONENT(ext ${src} EXT)
01861         IF(ext STREQUAL .f)
01862         IF(src STREQUAL trte.f)
01863         SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
01864         STRING(REPLACE ".f" ".c" src ${src})
01865         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
01866         SET(output ${src})
01867         SET(cmd f2c)
01868         IF(NOT WINDOWS)
01869         IF(CMAKE_SIZEOF_VOID_P STREQUAL 8)
01870         SET(cmd valgrind f2c)  # f2c seems to be buggy on 64 bits ... but with valgrind, it works :)
01871         ENDIF()
01872         ENDIF(NOT WINDOWS)
01873         ADD_CUSTOM_COMMAND(
01874         OUTPUT ${output}
01875         COMMAND ${cmd} ${input}
01876         MAIN_DEPENDENCY ${input}
01877         )
01878         ELSE(src STREQUAL trte.f)
01879         SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
01880         STRING(REPLACE ".f" ".o" src ${src})
01881         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
01882         SET(output ${src})
01883         IF(WINDOWS)
01884         SET(F77 g77)
01885         ELSE(WINDOWS)
01886         SET(F77 gfortran)
01887         ENDIF(WINDOWS)
01888         ADD_CUSTOM_COMMAND(
01889         OUTPUT ${output}
01890         COMMAND ${F77} -c -o ${output} ${input}
01891         MAIN_DEPENDENCY ${input}
01892         )
01893         ENDIF(src STREQUAL trte.f)
01894         ENDIF(ext STREQUAL .f)
01895         SET(srcs ${srcs} ${src})
01896         ENDFOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
01897         ''')
01898         newlines.append(r'''
01899         SET(l ${nodist_${amname}_SOURCES} ${UIC_FILES})
01900         FOREACH(f ${l})
01901         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${f})
01902         SET(srcs ${srcs} ${src})
01903         ENDFOREACH(f ${l})
01904         ''')
01905         newlines.append(r'''
01906         SET(build_srcs)
01907         SET(l ${nodist_${amname}_SOURCES} ${BUILT_SOURCES})
01908         FOREACH(f ${l})
01909         GET_FILENAME_COMPONENT(ext ${f} EXT)
01910         IF(ext STREQUAL .py)
01911         SET(fff)
01912         ELSE(ext STREQUAL .py)
01913         SET(fff ${CMAKE_CURRENT_BINARY_DIR}/${f})
01914         ENDIF(ext STREQUAL .py)
01915         IF(fff)
01916         IF(build_srcs)
01917         LIST(FIND build_srcs ${fff} index)
01918         IF(NOT index EQUAL -1)
01919         SET(fff)
01920         ENDIF(NOT index EQUAL -1)
01921         ENDIF(build_srcs)
01922         ENDIF(fff)
01923         IF(fff)
01924         SET(build_srcs ${build_srcs} ${fff})
01925         ENDIF(fff)
01926         ENDFOREACH(f ${l})
01927         ''')
01928         # --
01929         # Add the library to cmake
01930         # --
01931         newlines.append(r'''
01932         ADD_LIBRARY(${name} ${type} ${srcs})
01933         ''')
01934         # --
01935         # The compilation flags
01936         # --
01937         self.setCompilationFlags(key, newlines)
01938         # --
01939         newlines.append(r'''
01940         SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${VERSION_INFO} SOVERSION ${SOVERSION_INFO})
01941         ''')
01942         # --
01943         self.setLibAdd(key, newlines)
01944         # --
01945         if 1: # key != "noinst_LTLIBRARIES":
01946             newlines.append(r'''
01947             SET(key %s)
01948             '''%(key))
01949             newlines.append(r'''
01950             SET(test ON)
01951             IF(${key} STREQUAL noinst_LTLIBRARIES)
01952             SET(test OFF)
01953             ENDIF(${key} STREQUAL noinst_LTLIBRARIES)
01954             ''')
01955             if self.module == "netgen" :
01956                 newlines.append(r'''
01957                 IF(${key} STREQUAL noinst_LTLIBRARIES)
01958                 IF(WINDOWS)
01959                 SET(test ON)
01960                 ENDIF(WINDOWS)
01961                 ENDIF(${key} STREQUAL noinst_LTLIBRARIES)
01962                 ''')
01963                 pass
01964             newlines.append(r'''
01965             IF(test)
01966             ''')
01967             if self.module in ["medfile", "netgen"]:
01968                 newlines.append(r'''
01969                 SET(DEST lib)
01970                 ''')
01971             else:
01972                 newlines.append(r'''
01973                 SET(DEST lib/salome)
01974                 ''')
01975                 pass
01976             newlines.append(r'''
01977             IF(BEGIN_WITH_lib)
01978             INSTALL(TARGETS ${name} DESTINATION ${DEST})
01979             ''')
01980             if self.module == "gui":
01981                 newlines.append(r'''
01982                 FOREACH(lib SalomePyQt)
01983                 IF(name STREQUAL lib)
01984                 IF(WINDOWS)
01985                 IF(CMAKE_BUILD_TYPE STREQUAL Release)
01986                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}.pyd)
01987                 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
01988                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}_d.pyd)
01989                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
01990                 ELSE(WINDOWS)
01991                 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION ${DEST} RENAME ${name}.so)
01992                 ENDIF(WINDOWS)
01993                 ENDIF(name STREQUAL lib)
01994                 ENDFOREACH(lib SalomePyQt)
01995                 FOREACH(lib SalomePy)
01996                 IF(name STREQUAL lib)
01997                 IF(WINDOWS)
01998                 IF(CMAKE_BUILD_TYPE STREQUAL Release)
01999                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.pyd)
02000                 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
02001                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}_d.pyd)
02002                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
02003                 ENDIF(WINDOWS)
02004                 ENDIF(name STREQUAL lib)
02005                 ENDFOREACH(lib SalomePy)
02006                 ''')
02007                 pass
02008             if self.module == "geom":
02009                 newlines.append(r'''
02010                 IF(WINDOWS)
02011                 STRING(REGEX MATCH "Export" ISExport ${name})
02012                 IF(ISExport)
02013                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
02014                 ENDIF(ISExport)
02015                 STRING(REGEX MATCH "Import" ISImport ${name})
02016                 IF(ISImport)
02017                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
02018                 ENDIF(ISImport)
02019                 ENDIF(WINDOWS)
02020                 ''')
02021                 pass
02022             newlines.append(r'''
02023             ELSE(BEGIN_WITH_lib)
02024             ''')
02025             newlines.append(r'''
02026             IF(WINDOWS)
02027             INSTALL(TARGETS ${name} DESTINATION ${salomepythondir})
02028             IF(CMAKE_BUILD_TYPE STREQUAL Release)
02029             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}.pyd)
02030             ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
02031             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}_d.pyd)
02032             ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
02033             ELSE(WINDOWS)
02034             GET_TARGET_PROPERTY(version ${name} VERSION)
02035             GET_TARGET_PROPERTY(soversion ${name} SOVERSION)
02036             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${version})
02037             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${soversion})
02038             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so)
02039             ENDIF(WINDOWS)
02040             ''')
02041             newlines.append(r'''
02042             ENDIF(BEGIN_WITH_lib)
02043             ''')
02044             newlines.append(r'''
02045             ENDIF(test)
02046             ''')
02047             pass
02048         # --
02049         newlines.append(r'''
02050         ENDFOREACH(amname ${%s})
02051         '''%(key))
02052         # --
02053         return
02054     
02055     def addBinTarget(self, key, newlines):
02056         # --
02057         newlines.append(r'''
02058         FOREACH(amname ${%s})
02059         '''%(key))
02060         # --
02061         newlines.append(r'''
02062         SET(test ON)
02063         ''')
02064         if key == "check_PROGRAMS":
02065             newlines.append(r'''
02066             IF(bin_PROGRAMS)
02067             STRING(REGEX MATCH ${amname} is_present ${bin_PROGRAMS})
02068             IF(is_present)
02069             SET(test OFF)
02070             ENDIF(is_present)
02071             ENDIF(bin_PROGRAMS)
02072             ''')
02073             pass
02074         newlines.append(r'''
02075         IF(test)
02076         ''')
02077         # --
02078         newlines.append(r'''
02079         SET(name "${amname}_exe")
02080         SET(srcs ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
02081         SET(l ${nodist_${amname}_SOURCES})
02082         FOREACH(f ${l})
02083         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${f})
02084         SET(srcs ${srcs} ${src})
02085         ENDFOREACH(f ${l})
02086         LIST(LENGTH srcs nb)
02087         IF(nb)
02088         ADD_EXECUTABLE(${name} ${srcs})
02089         ''')
02090         # --
02091         self.setCompilationFlags(key, newlines)
02092         # --
02093         self.setLibAdd(key, newlines)
02094         # --
02095         if self.module in ["jobmanager", "medfile", "netgen"]:
02096             newlines.append(r'''
02097             SET(DEST bin)
02098             ''')
02099         else:
02100             newlines.append(r'''
02101             SET(DEST bin/salome)
02102             ''')
02103             pass
02104         # --
02105         if key == "bin_PROGRAMS":
02106             newlines.append(r'''
02107             IF(WINDOWS)
02108             INSTALL(TARGETS ${name} DESTINATION ${DEST})
02109             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe DESTINATION ${DEST} RENAME ${amname}.exe)
02110             INSTALL(CODE "FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe)")
02111             ELSE(WINDOWS)
02112             SET(PERMS)
02113             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02114             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02115             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02116             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name} DESTINATION ${DEST} PERMISSIONS ${PERMS} RENAME ${amname})
02117             ENDIF(WINDOWS)
02118             ''')
02119             pass
02120         # --
02121         newlines.append(r'''
02122         ENDIF(nb)
02123         ''')
02124         # --
02125         newlines.append(r'''
02126         ENDIF(test)
02127         ''')
02128         newlines.append(r'''
02129         ENDFOREACH(amname ${%s})
02130         '''%(key))
02131         # --
02132         return
02133     
02134     def addInstallTarget(self, key, destination, newlines):
02135         newlines.append(r"FOREACH(f ${%s})"%(key))
02136         newlines.append(r'''
02137         SET(DEST %s)
02138         '''%(destination))
02139         newlines.append(r'''
02140         STRING(COMPARE EQUAL ${f} SALOMEconfig.h.in test_SALOMEconfig.h.in)
02141         IF(test_SALOMEconfig.h.in)
02142         INSTALL(FILES SALOMEconfig.ref.in DESTINATION ${DEST} RENAME SALOMEconfig.h.in)
02143         ELSE(test_SALOMEconfig.h.in)
02144         SET(dummy dummy-NOTFOUND)
02145         MARK_AS_ADVANCED(dummy)
02146         # FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${f})
02147         FIND_FILE(dummy ${f} PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
02148         IF(dummy)
02149         ''')
02150         if key in ['dist_salomescript_SCRIPTS']:
02151             newlines.append(r'''
02152             SET(PERMS)
02153             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02154             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02155             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02156             INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
02157             ''')
02158         else:
02159             newlines.append(r'''
02160             GET_FILENAME_COMPONENT(ext ${f} EXT)
02161             IF(ext STREQUAL .py)
02162             IF(DEST STREQUAL bin/salome)
02163             SET(PERMS)
02164             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02165             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02166             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02167             INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
02168             ELSE(DEST STREQUAL bin/salome)
02169             INSTALL(FILES ${f} DESTINATION ${DEST})
02170             ENDIF(DEST STREQUAL bin/salome)
02171             ELSE(ext STREQUAL .py)
02172             INSTALL(FILES ${f} DESTINATION ${DEST})
02173             ENDIF(ext STREQUAL .py)
02174             ''')
02175             pass
02176         newlines.append(r'''
02177         ELSE(dummy)
02178         GET_FILENAME_COMPONENT(ext ${f} EXT)
02179         IF(ext STREQUAL .qm)
02180         STRING(REGEX REPLACE .qm .ts input ${f})
02181         ''')
02182         if self.module in ["kernel", "gui", "yacs"]:
02183             newlines.append(r'''
02184             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/resources/${input})
02185             ''')
02186         else:
02187             newlines.append(r'''
02188             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
02189             ''')
02190             pass
02191         newlines.append(r'''
02192         SET(output ${CMAKE_CURRENT_BINARY_DIR}/${f})
02193         # ADD_CUSTOM_COMMAND(
02194         # OUTPUT ${output}
02195         # COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output}
02196         # MAIN_DEPENDENCY ${input}
02197         # )
02198         EXECUTE_PROCESS(COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output})
02199         ENDIF(ext STREQUAL .qm)
02200         INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${DEST})
02201         ENDIF(dummy)
02202         ENDIF(test_SALOMEconfig.h.in)
02203         ''')
02204         newlines.append(r'''
02205         GET_FILENAME_COMPONENT(ext ${f} EXT)
02206         IF(ext STREQUAL .py)
02207         INSTALL(CODE "SET(PYTHON_FILE ${f})")
02208         INSTALL(CODE "SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})")
02209         INSTALL(CODE "SET(DEST ${DEST})")
02210         INSTALL(CODE "SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})")
02211         ''')
02212         if self.module == "kernel":
02213             newlines.append('''
02214             IF(f STREQUAL SALOME_ContainerPy.py)
02215             ELSE(f STREQUAL SALOME_ContainerPy.py)
02216             IF(f STREQUAL am2cmake.py)
02217             ELSE(f STREQUAL am2cmake.py)
02218             IF(f STREQUAL copytree1.py)
02219             ELSE(f STREQUAL copytree1.py)
02220             INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
02221             ENDIF(f STREQUAL copytree1.py)
02222             ENDIF(f STREQUAL am2cmake.py)
02223             ENDIF(f STREQUAL SALOME_ContainerPy.py)
02224             ''')
02225         else:
02226             newlines.append('''
02227             STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
02228             INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
02229             ''')
02230             pass
02231         newlines.append(r'''
02232         ENDIF(ext STREQUAL .py)
02233         ''') 
02234         newlines.append(r"ENDFOREACH(f ${%s})"%(key))
02235         return
02236     
02237     def writeListsFile(self):
02238         f = open(self.listsFile, "w")
02239         f.write(self.content)
02240         f.close()
02241         return
02242     
02243     pass
02244 
02245 def convertAmFile(the_root, root, dirs, files, f, module):
02246     cmake = CMakeFile(the_root, root, dirs, files, f, module)
02247     cmake.writeListsFile()
02248     return
02249 
02250 def usage(exit_status):
02251     from sys import exit
02252     from sys import argv
02253     print "Usage: %s --module"%(argv[0])
02254     exit(exit_status)
02255     return
02256 
02257 if __name__ == "__main__":
02258     #
02259     from sys import argv
02260     if len(argv) != 2:
02261         usage(1)
02262         pass
02263     #
02264     module = argv[1]
02265     if module.find('--') != 0:
02266         usage(1)
02267         pass
02268     module = module[2:]
02269     if len(module) == 0:
02270         usage(1)
02271         pass
02272     #
02273     from os import getcwd
02274     the_root = getcwd()
02275     #
02276     nok = 0
02277     #
02278     from os import walk
02279     for root, dirs, files in walk(the_root):
02280         # --
02281         # E.A. : Remove 'CVS' in dirs
02282         # E.A. : It allows to not recurse in CVS dirs
02283         # E.A. : See os module python documentation
02284         # --
02285         try:
02286             dirs.remove('CVS')
02287         except ValueError:
02288             pass
02289         # --
02290         if "Makefile.am.cmake" in files:
02291             if "Makefile.am" in files:
02292                 files.remove("Makefile.am")
02293                 pass
02294             pass
02295         # --
02296         from sys import stdout
02297         for f in files:
02298             if f in ["Makefile.am", "Makefile.am.cmake"]:
02299                 convertAmFile(the_root, root, dirs, files, f, module)
02300                 nok += 1
02301                 pass
02302             pass
02303         pass
02304     #
02305     if nok:
02306         if nok == 1:
02307             msg = "%s file has been converted to cmake"%(nok)
02308         else:
02309             msg = "%s files have been converted to cmake"%(nok)
02310             pass
02311         stdout.write(msg)
02312         stdout.write("\n")
02313         stdout.flush()
02314         pass
02315     pass