Back to index

salome-kernel  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             "SalomeKernelHelpers",
00249             ]
00250         gui_list = [
00251             "caf",
00252             "CAM",
00253             "CASCatch",
00254             "DDS",
00255             "Event",
00256             "GLViewer",
00257             "LightApp",
00258             "LogWindow",
00259             "ObjBrowser",
00260             "OCCViewer",
00261             "OpenGLUtils",
00262             "Plot2d",
00263             "PyConsole",
00264             "PyInterp",
00265             "QDS",
00266             "qtx",
00267             "QxScene",
00268             "SalomeApp",
00269             "SalomeAppTest",
00270             "SalomeIDLGUI",
00271             "SalomeObject",
00272             "SalomePrs",
00273             "SalomePyQtGUILight",
00274             "SalomePyQtGUI",
00275             "SalomePyQt",
00276             "SalomePy",
00277             "SalomeSession",
00278             "SalomeStyle",
00279             "SOCC",
00280             "SPlot2d",
00281             "std",
00282             "SUITApp",
00283             "suit",
00284             "SUPERVGraph",
00285             "SVTK",
00286             "ToolsGUI",
00287             "ViewerTools",
00288             "VTKViewer",
00289             "vtkEDFOverloads",
00290             "vtkTools"
00291             ]
00292         geom_list = [
00293             "AdvancedGUI",
00294             "BasicGUI",
00295             "BlocksGUI",
00296             "BooleanGUI",
00297             "BREPExport",
00298             "BREPImport",
00299             "BuildGUI",
00300             "DisplayGUI",
00301             "DlgRef",
00302             "EntityGUI",
00303             "GenerationGUI",
00304             "GEOMAlgo",
00305             "GEOMAlgo_NEW",
00306             "GEOMArchimede",
00307             "GEOMBase",
00308             "GEOMbasic",
00309             "GEOMClient",
00310             "GEOMEngine",
00311             "GEOMFiltersSelection",
00312             "GEOMimpl",
00313             "GEOMObject",
00314             "GEOMSketcher",
00315             "GEOM",
00316             "GEOM_SupervEngine",
00317             "GEOMToolsGUI",
00318             "GroupGUI",
00319             "IGESExport",
00320             "IGESImport",
00321             "MeasureGUI",
00322            "Material",
00323             "NMTDS",
00324             "NMTDS_NEW",
00325             "NMTTools",
00326             "NMTTools_NEW",
00327             "OCC2VTK",
00328             "OperationGUI",
00329             "PrimitiveGUI",
00330             "RepairGUI",
00331             "SalomeIDLGEOM",
00332             "ShHealOper",
00333             "STEPExport",
00334             "STEPImport",
00335             "STLExport",
00336             "TransformationGUI",
00337             "VTKExport",
00338             ]
00339         med_list = [
00340             "interpkernel",
00341             "InterpKernelTest",
00342             "MEDClientcmodule",
00343             "medcouplingclient",
00344             "medcouplingcorba",
00345             "medcouplingremapper",
00346             "medcoupling",
00347             "MEDEngine",
00348             "medloader",
00349             "MEDMEMCppTest",
00350             "MEDMEMImpl",
00351             "medmem",
00352             "MED",
00353             "medsplitter",
00354             "MEDSPLITTERTest",
00355             "med_V2_1",
00356             "MEDWrapperBase",
00357             "MEDWrapper",
00358             "MEDWrapper_V2_1",
00359             "MEDWrapper_V2_2",
00360             "paramedcouplingcorba",
00361             "paramedloader",
00362             "paramedmemcompo",
00363             "paramedmem",
00364             "ParaMEDMEMTest",
00365             "SalomeIDLMED",
00366             "SalomeIDLMEDTests",
00367             ]
00368         smesh_list = [
00369             "GeomSelectionTools",
00370             "MEFISTO2D",
00371             "MeshDriverDAT",
00372             "MeshDriverMED",
00373             "MeshDriver",
00374             "MeshDriverSTL",
00375             "MeshDriverUNV",
00376             "SalomeIDLSMESH",
00377             "SMDS",
00378             "SMESHClient",
00379             "SMESHControls",
00380             "SMESHDS",
00381             "SMESHEngine",
00382             "SMESHFiltersSelection",
00383             "SMESHimpl",
00384             "SMESHObject",
00385             "SMESH",
00386             "SMESHUtils",
00387             "StdMeshersEngine",
00388             "StdMeshersGUI",
00389             "StdMeshers",
00390             ]
00391         full_list  = cas_list + vtk_list
00392         full_list += kernel_list + gui_list
00393         full_list += geom_list + med_list + smesh_list
00394         # --
00395         # E.A. : sort by len before substitution ...
00396         # Why ? Thing to "-lMEDWrapper" then "-lMEDWrapper_V2_1" substition
00397         # And you understand ...
00398         # --
00399         full_list.sort(cmp = lambda x, y : cmp(len(y), len(x)))
00400         # --
00401         for key in full_list:
00402             content = content.replace("-l%s"%(key), "${%s}"%(key))
00403          
00404             pass
00405         
00406         # --
00407         # Split content in lines to treat each one separately
00408         # --
00409         lines = content.split('\n')
00410         
00411         # --
00412         # newlines contains the lines of the future CMakeLists.txt file
00413         # --
00414         newlines = []
00415         
00416         # --
00417         # opened_ifs is used to deals with nested conditionnals
00418         # --
00419         opened_ifs = []
00420         
00421         # --
00422         # the __thedict__ dictionnary contains key, val
00423         # of the Makefile.am file
00424         # --
00425         self.__thedict__ = {}
00426         
00427         # --
00428         # Initialize file ... mainly includes other cmake files
00429         # --
00430         self.initialize(newlines)
00431         
00432         # --
00433         # Do the job for each line
00434         # --
00435         for line in lines:
00436             self.treatLine(line, newlines, opened_ifs)
00437             pass
00438         
00439         # --
00440         # Finalize file ... it is in here the cmake job is done
00441         # --
00442         self.finalize(newlines)
00443         
00444         # --
00445         # Concatenate newlines into content
00446         # --
00447         content = '\n'.join(newlines)
00448         
00449         # --
00450         # Add a CR at end if necessary
00451         # --
00452         lines = content.split('\n')
00453         # lines = [ l.strip() for l in lines ]
00454         if len(lines[-1]) != 0:
00455             lines.append('')
00456             pass
00457         content = '\n'.join(lines)
00458         
00459         # --
00460         self.content  = "# ---------------------------------------------------------------------\n"
00461         self.content += "# This file was automatically generated by am2cmake (erwan.adam@cea.fr)\n"
00462         self.content += "# ---------------------------------------------------------------------\n"
00463         self.content += content
00464         
00465         # --
00466         return
00467     
00468     def initialize(self, newlines):
00469         if self.root == self.the_root:
00470             # --
00471             newlines.append("""
00472             CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
00473             IF(COMMAND cmake_policy)
00474             cmake_policy(SET CMP0003 NEW)
00475             ENDIF(COMMAND cmake_policy)
00476             """)
00477             # --
00478             newlines.append("""
00479             ENABLE_TESTING()
00480             """)
00481             # --
00482             newlines.append("""
00483             SET(MODULE %s)
00484             """%(self.module.upper()))
00485             # --
00486             if self.module == "netgen":
00487                 newlines.append("""
00488                 INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindPLATFORM.cmake)
00489                 INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindCAS.cmake)
00490                 """)
00491             else:
00492                 if self.module == "kernel":
00493                     newlines.append("""
00494                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00495                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00496                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00497                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00498                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00499                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00500                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00501                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00502                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00503                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00504                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00505                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00506                     INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSPHINX.cmake)
00507                     """)
00508                     pass
00509                 else:
00510                     if self.module == "med":
00511                         newlines.append("""
00512                         SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
00513                         IF(KERNEL_ROOT_DIR)
00514                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00515                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00516                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00517                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00518                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00519                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00520                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00521                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00522                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00523                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00524                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00525                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00526                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
00527                         ELSE(KERNEL_ROOT_DIR)
00528                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindPLATFORM.cmake)
00529                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindMPI.cmake)
00530                         ENDIF(KERNEL_ROOT_DIR)
00531                         """)
00532                     else:
00533                         newlines.append("""
00534                         SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
00535                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
00536                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
00537                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
00538                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
00539                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindMPI.cmake)
00540                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
00541                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
00542                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
00543                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
00544                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
00545                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
00546                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
00547                         INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
00548                         """)
00549                         pass
00550                     if self.module == "gui":
00551                         newlines.append("""
00552                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindCAS.cmake)
00553                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQT4.cmake)
00554                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
00555                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindVTK.cmake)
00556                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQWT.cmake)
00557                         INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
00558                         """)
00559                     else:
00560                         newlines.append("""
00561                         SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR})
00562                         IF(GUI_ROOT_DIR)
00563                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindCAS.cmake)
00564                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQT4.cmake)
00565                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
00566                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindVTK.cmake)
00567                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQWT.cmake)
00568                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
00569                         INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindGUI.cmake)
00570                         ENDIF(GUI_ROOT_DIR)
00571                         """)
00572                         if self.module == "med":
00573                             #METIS must be after PARMETIS to prevent to activate METIS if PARMETIS already exists
00574                             newlines.append("""
00575                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindPARMETIS.cmake)
00576                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindMETIS.cmake)
00577                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSCOTCH.cmake)
00578                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSPLITTER.cmake)
00579                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindRENUMBER.cmake)
00580                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00581                             IF(WINDOWS)
00582                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
00583                             ENDIF(WINDOWS)
00584                             """)
00585                             pass
00586                         if self.module == "smesh":
00587                             newlines.append("""
00588                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00589                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00590                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00591                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00592                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00593                             INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake)
00594                             """)
00595                             pass
00596                         if self.module == "geom":
00597                             newlines.append("""
00598                             INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake)
00599                             """)
00600                             pass
00601 
00602                         if self.module == "netgenplugin":
00603                             newlines.append("""
00604                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00605                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00606                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00607                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00608                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00609                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00610                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindNETGEN.cmake)
00611                             """)
00612                             pass
00613                         if self.module == "blsurfplugin":
00614                             newlines.append("""
00615                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00616                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00617                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00618                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00619                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00620                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00621                             INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindBLSURF.cmake)
00622                             """)
00623                             pass
00624                         if self.module in ["ghs3dplugin", "hexoticplugin"]:
00625                             newlines.append("""
00626                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00627                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00628                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00629                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00630                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00631                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00632                             """)
00633                             pass
00634                         if self.module == "ghs3dprlplugin":
00635                             newlines.append("""
00636                             SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
00637                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00638                             SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
00639                             INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
00640                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00641                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00642                             INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
00643                             """)
00644                             pass
00645                         if self.module == "visu":
00646                             newlines.append("""
00647                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00648                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00649                             """)
00650                             pass
00651                         if self.module == "yacs":
00652                             newlines.append("""
00653                             INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindEXPAT.cmake)
00654                             INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindGRAPHVIZ.cmake)
00655                             INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake)
00656                             """)
00657                             pass
00658                         if self.module == "hxx2salome":
00659                             newlines.append("""
00660                             SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
00661                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
00662                             INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
00663                             """)
00664                             pass
00665                         pass
00666                     pass
00667                 pass
00668             # --
00669             newlines.append("""
00670             SET(DOXYGEN_IS_OK 0)
00671             """)
00672             if self.module not in ['med']:
00673                 newlines.append("""
00674                 IF(WINDOWS)
00675                 SET(CPPUNIT_IS_OK 0)
00676                 ENDIF(WINDOWS)
00677                 """)
00678                 pass
00679             # --
00680             if self.module == "kernel":
00681                 newlines.append("""
00682                 SET(WITH_LOCAL 1)
00683                 SET(WITH_BATCH 1)
00684                 SET(CALCIUM_IDL_INT_F77 long)
00685                 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
00686                 SET(LONG_OR_INT int)
00687                 """)
00688             elif self.module == "gui":
00689                 newlines.append("""
00690                 SET(GUI_ENABLE_CORBA ${CORBA_GEN})
00691                 SET(ENABLE_VTKVIEWER ON)
00692                 SET(ENABLE_SALOMEOBJECT ON)
00693                 SET(ENABLE_OCCVIEWER ON)
00694                 SET(ENABLE_GLVIEWER ON)
00695                 SET(ENABLE_PLOT2DVIEWER ON)
00696                 SET(ENABLE_PYCONSOLE ON)
00697                 SET(ENABLE_SUPERVGRAPHVIEWER ON)
00698                 SET(ENABLE_QXGRAPHVIEWER ON)
00699                 """)
00700                 pass
00701             elif self.module == "jobmanager":
00702                 newlines.append("""
00703                 IF(GUI_ROOT_DIR)
00704                 SET(HAS_GUI ON)
00705                 ENDIF(GUI_ROOT_DIR)
00706                 """)
00707                 pass
00708             elif self.module == "geom":
00709                 newlines.append("""
00710                 IF(GUI_ROOT_DIR)
00711                 SET(GEOM_ENABLE_GUI ON)
00712                 ENDIF(GUI_ROOT_DIR)
00713                 """)
00714                 pass
00715             elif self.module == "medfile":
00716                 newlines.append("""
00717                 SET(MED_NUM_MAJEUR 3)
00718                 SET(MED_NUM_MINEUR 0)
00719                 SET(MED_NUM_RELEASE 3)
00720                 SET(LONG_OR_INT int)
00721                 IF(NOT WINDOWS)
00722                 SET(FLIBS -lgfortranbegin -lgfortran)
00723                 ENDIF(NOT WINDOWS)
00724                 """)
00725                 pass
00726             elif self.module == "med":
00727                 newlines.append("""
00728                 IF(KERNEL_ROOT_DIR)
00729                 SET(MED_ENABLE_KERNEL ON)
00730                 IF(NOT WINDOWS)
00731                 SET(MED_ENABLE_SPLITTER ON)
00732                 ENDIF(NOT WINDOWS)
00733                 ENDIF(KERNEL_ROOT_DIR)
00734                 IF(GUI_ROOT_DIR)
00735                 SET(MED_ENABLE_GUI ON)
00736                 ENDIF(GUI_ROOT_DIR)
00737                 """)
00738                 pass
00739             elif self.module == "smesh":
00740                 newlines.append("""
00741                 IF(GUI_ROOT_DIR)
00742                 SET(SMESH_ENABLE_GUI ON)
00743                 ENDIF(GUI_ROOT_DIR)
00744                 """)
00745                 pass
00746             elif self.module == "netgen":
00747                 newlines.append("""
00748                 SET(OCCFLAGS ${CAS_CPPFLAGS})
00749                 SET(OCCLIBS ${CAS_LDPATH})
00750                 SET(OCCLIBS ${OCCLIBS} ${TKernel} ${TKGeomBase} ${TKMath} ${TKG2d} ${TKG3d} ${TKXSBase} ${TKOffset} ${TKFillet} ${TKShHealing})
00751                 SET(OCCLIBS ${OCCLIBS} ${TKMesh} ${TKMeshVS} ${TKTopAlgo} ${TKGeomAlgo} ${TKBool} ${TKPrim} ${TKBO} ${TKIGES} ${TKBRep})
00752                 SET(OCCLIBS ${OCCLIBS} ${TKSTEPBase} ${TKSTEP} ${TKSTL} ${TKSTEPAttr} ${TKSTEP209} ${TKXDESTEP} ${TKXDEIGES} ${TKXCAF} ${TKLCAF} ${FWOSPlugin})
00753                 """)
00754                 pass
00755             elif self.module == "netgenplugin":
00756                 newlines.append("""
00757                 IF(GUI_ROOT_DIR)
00758                 SET(NETGENPLUGIN_ENABLE_GUI ON)
00759                 ENDIF(GUI_ROOT_DIR)
00760                 """)
00761                 pass
00762             elif self.module == "blsurfplugin":
00763                 newlines.append("""
00764                 IF(GUI_ROOT_DIR)
00765                 SET(BLSURFPLUGIN_ENABLE_GUI ON)
00766                 ENDIF(GUI_ROOT_DIR)
00767                 """)
00768                 pass
00769             elif self.module == "ghs3dplugin":
00770                 newlines.append("""
00771                 IF(GUI_ROOT_DIR)
00772                 SET(GHS3DPLUGIN_ENABLE_GUI ON)
00773                 ENDIF(GUI_ROOT_DIR)
00774                 """)
00775                 pass
00776             elif self.module == "hexoticplugin":
00777                 newlines.append("""
00778                 IF(GUI_ROOT_DIR)
00779                 SET(HEXOTICPLUGIN_ENABLE_GUI ON)
00780                 ENDIF(GUI_ROOT_DIR)
00781                 """)
00782                 pass
00783             elif self.module == "ghs3dprlplugin":
00784                 newlines.append("""
00785                 IF(GUI_ROOT_DIR)
00786                 SET(GHS3DPRLPLUGIN_ENABLE_GUI ON)
00787                 ENDIF(GUI_ROOT_DIR)
00788                 """)
00789                 pass
00790             elif self.module == "yacs":
00791                 newlines.append("""
00792                 SET(SALOME_KERNEL ON)
00793                 SET(HAS_GUI ON)
00794                 SET(WITH_QT4 ON)
00795                 """)
00796                 pass
00797             # --
00798             newlines.append("""
00799             set(VERSION 6.5.0)
00800             set(SHORT_VERSION 6.5)
00801             set(XVERSION 0x060500)
00802             """)
00803             pass
00804         # --
00805         newlines.append("""
00806         SET(VERSION_INFO 0.0.0)
00807         SET(SOVERSION_INFO 0)
00808         SET(SUBDIRS)
00809         SET(bin_PROGRAMS)
00810         SET(AM_CPPFLAGS -I${CMAKE_BINARY_DIR} )
00811         SET(AM_CXXFLAGS -I${CMAKE_BINARY_DIR})
00812         SET(LDADD)
00813         SET(pythondir lib/python${PYTHON_VERSION}/site-packages)
00814         SET(salomepythondir ${pythondir}/salome)
00815         SET(salomepypkgdir ${salomepythondir}/salome)
00816         """)
00817         
00818         if self.module == "smesh" and self.root[-len('SMESH_PY'):] == 'SMESH_PY':
00819            newlines.append("""
00820            SET(smeshpypkgdir ${salomepythondir}/salome/smesh)
00821            """)
00822            pass
00823         if self.module == "netgen":
00824             newlines.append(r'''
00825             SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY -I${CMAKE_CURRENT_SOURCE_DIR})
00826             ''')
00827         elif self.module == "kernel":
00828             newlines.append(r'''
00829             SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h)
00830             SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h)
00831             ''')
00832         else:
00833             if self.module not in ["yacs"]:
00834                 newlines.append(r'''
00835                 IF(KERNEL_ROOT_DIR)
00836                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DHAVE_SALOME_CONFIG -I${KERNEL_ROOT_DIR}/include/salome -include SALOMEconfig.h)
00837                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DHAVE_SALOME_CONFIG -I${KERNEL_ROOT_DIR}/include/salome -include SALOMEconfig.h)
00838                 ENDIF(KERNEL_ROOT_DIR)
00839                 ''')
00840                 pass
00841             if self.module == "gui":
00842                 newlines.append(r'''
00843                 IF(KERNEL_ROOT_DIR)
00844                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DWITH_SALOMEDS_OBSERVER -DSUIT_ENABLE_PYTHON)
00845                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DWITH_SALOMEDS_OBSERVER -DSUIT_ENABLE_PYTHON)
00846                 ENDIF(KERNEL_ROOT_DIR)
00847                 ''')
00848                 pass
00849             if self.module in ["smesh", "netgenplugin", "blsurfplugin", "ghs3dplugin", "hexoticplugin"]:
00850                 newlines.append(r'''
00851                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DWITH_SMESH_CANCEL_COMPUTE)
00852                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DWITH_SMESH_CANCEL_COMPUTE)
00853                 ''')
00854                 pass
00855             if self.module == "ghs3dplugin":
00856     # TODO: Auto-detect TetGen-GHS3D version automatically
00857                 newlines.append(r'''
00858                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DGHS3D_VERSION=42)
00859                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DGHS3D_VERSION=42)
00860                 ''')
00861                 pass              
00862             if self.module == "hxx2salome":
00863                 key = "_SRC"
00864                 if self.the_root[-len(key):] != key:
00865                     msg = "Source dir must finished with %s !"%(key)
00866                     raise Exception(msg)
00867                 hxxmodule = self.the_root[:-len(key)]
00868                 from os.path import basename
00869                 hxxmodule = basename(hxxmodule)
00870                 hxxmodule = hxxmodule.lower()
00871                 self.hxxmodule = hxxmodule
00872                 newlines.append(r'''
00873                 SET(HXXCPP_ROOT_DIR $ENV{%sCPP_ROOT_DIR})
00874                 SET(AM_CPPFLAGS ${AM_CPPFLAGS} -I${HXXCPP_ROOT_DIR}/include)
00875                 SET(AM_CXXFLAGS ${AM_CXXFLAGS} -I${HXXCPP_ROOT_DIR}/include)
00876                 SET(LDADD ${LDADD} -L${HXXCPP_ROOT_DIR}/lib)
00877                 '''%(hxxmodule.upper()))
00878                 pass
00879             pass
00880         # --
00881         return
00882     
00883     def treatLine(self, line, newlines, opened_ifs):
00884         
00885         # --
00886         # Print the comment above the line itself
00887         # --
00888         if line.find('#') >= 0:
00889             fields = line.split('#')
00890             line = fields[0]
00891             comment = '#'.join([''] + fields[1:])
00892             newlines.append(comment)
00893             if len(line) == 0:
00894                 return
00895             pass
00896         
00897         # --
00898         # If the line begins with 'include ', just comment it
00899         # --
00900         if line.find("include ") == 0:
00901             if line.find("include $(top_srcdir)/config/automake.common") == 0:
00902                 for l in [
00903                     "MAINTAINERCLEANFILES = Makefile.in",
00904                     "AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include",
00905                     "AM_FFLAGS=-I$(top_srcdir)/include  -I$(top_builddir)/include",
00906                     "AM_FCFLAGS=-I$(top_srcdir)/include  -I$(top_builddir)/include",
00907                     "AM_CPPFLAGS+=@HDF5_CPPFLAGS@",
00908                     "AM_LDFLAGS=@HDF5_LDFLAGS@",
00909                     ]:
00910                     self.treatLine(l, newlines, opened_ifs)
00911                     pass
00912                 pass
00913             else:
00914                 newlines.append("# " + line)
00915                 pass
00916             return
00917         
00918         # --
00919         # If the line begins with '-include', just comment it
00920         # --
00921         if line.find("-include") == 0:
00922             newlines.append("# " + line)
00923             return
00924         
00925         # --
00926         # If the line is a definition of a make rule, just comment it
00927         # --
00928         if line.count(':') == 1:
00929             newlines.append("# " + line)
00930             return
00931         
00932         # --
00933         # A particuliar case where there are two ":" on the same line
00934         # --
00935         if line.find('install-exec-local:') == 0:
00936             newlines.append("# " + line)
00937             return
00938         
00939         # --
00940         # If the line begin by a tabulation, consider it's a makefile command and comment it
00941         # --
00942         if line.find("\t") == 0:
00943             newlines.append("# " + line)
00944             return
00945         
00946         # --
00947         # --
00948         key = "-version-info"
00949         if line.find(key) >= 0:
00950             # --
00951             before = line.split(key)[0]
00952             after = line[len(before)+len(key):]
00953             sep = after[0]
00954             after = after[1:]
00955             version_info = after.split()[0]
00956             line = line.replace(key+sep+version_info, "")
00957             # --
00958             version_info = version_info.replace(':', '.')
00959             soversion_info = version_info.split('.')[0]
00960             newlines.append("SET(VERSION_INFO " + version_info + ")")
00961             newlines.append("SET(SOVERSION_INFO " + soversion_info + ")")
00962             # --
00963             pass
00964         
00965         # --
00966         # Replace the $(TOTO) by ${TOTO}
00967         # Replace the @TOTO@  by ${TOTO}
00968         # --
00969         line = p_dollar.sub(r"${\1}", line)
00970         line = p_arobas.sub(r"${\1}", line)
00971         
00972         # --
00973         line = line.replace(r"${top_builddir}", r"${CMAKE_BINARY_DIR}")
00974         line = line.replace(r"${top_srcdir}", r"${CMAKE_SOURCE_DIR}")
00975         line = line.replace(r"${srcdir}", r"${CMAKE_CURRENT_SOURCE_DIR}")
00976         line = line.replace(r"${builddir}", r"${CMAKE_CURRENT_BINARY_DIR}")
00977         line = line.replace(r"${datadir}", r"${CMAKE_INSTALL_PREFIX}/share")
00978         
00979         # --
00980         # Check if the line is a 'if' condition
00981         # If yes, replace it by a cmake grammar
00982         # --
00983         match = p_if.match(line)
00984         if match:
00985             theif = match.group("val")
00986             if theif[0] == "!":
00987                 theif = "NOT " + theif[1:]
00988                 pass
00989             line = p_if.sub(r"IF(%s)"%(theif), line)
00990             opened_ifs.append(theif)
00991             newlines.append(line)
00992             return
00993         
00994         # --
00995         # Check if the line is a 'else' condition
00996         # If yes, replace it by a cmake grammar
00997         # --
00998         match = p_else.match(line)
00999         if match:
01000             line = "ELSE(%s)"%(opened_ifs[-1])
01001             newlines.append(line)
01002             return
01003         
01004         # --
01005         # Check if the line is a 'endif' condition
01006         # If yes, replace it by a cmake grammar
01007         # --
01008         match = p_endif.match(line)
01009         if match:
01010             line = "ENDIF(%s)"%(opened_ifs[-1])
01011             opened_ifs[-1:] = []
01012             newlines.append(line)
01013             return
01014         
01015         # --
01016         # Check if the line is an attribution '=' or '+='
01017         # --
01018         match = p_attribution.match(line)
01019         if match:
01020             self.treatAttribution(match, newlines)
01021             return
01022         
01023         # --
01024         newlines.append(line)
01025         
01026         # --
01027         return
01028     
01029     def treatAttribution(self, match, newlines):
01030         
01031         spaces = match.group("spaces")
01032         key = match.group("key")
01033         method = match.group("method")
01034         value = match.group("value")
01035         # print [spaces, key, method, value]
01036         
01037         # --
01038         # Open cmake SET command
01039         # --
01040         newlines.append(spaces + "SET(" + key)
01041         
01042         # --
01043         # If method is '+=', put the previous definition as first value
01044         # --
01045         if method == "+=":
01046             newlines.append("%s    ${%s}"%(spaces, key))
01047             pass
01048         
01049         # --
01050         fields = value.split()
01051         
01052         for i in range(len(fields)):
01053             newlines.append("%s    %s"%(spaces, fields[i]))
01054             pass
01055         
01056         # --
01057         if method == "+=":
01058             # --
01059             # The try: except KeyError is here if the +=
01060             # is an error which occurs in salome ...
01061             # --
01062             try:
01063                 self.__thedict__[key] += fields[:]
01064             except KeyError:
01065                 self.__thedict__[key] = fields[:]
01066                 pass
01067             pass
01068         else:
01069             self.__thedict__[key]  = fields[:]
01070             pass
01071         
01072         # --
01073         # Close cmake SET command
01074         # --
01075         
01076         newlines.append("%s)"%(spaces))
01077         
01078         return
01079     
01080     def finalize(self, newlines):
01081       
01082         # --
01083         # Convert the .in files in build dir
01084         # --
01085         upmod = ""
01086         if self.module == "hexoticplugin" :
01087           upmod = "HexoticPLUGIN"
01088         else :
01089           upmod = self.module.upper()
01090 
01091         import operator
01092         mod = self.module
01093         if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'):
01094             newlines.append(r'''
01095             SET(top_builddir
01096                 ${CMAKE_BINARY_DIR}
01097             )
01098             SET(top_srcdir 
01099                 ${CMAKE_SOURCE_DIR}
01100             )
01101             SET(srcdir 
01102                 ${CMAKE_CURRENT_SOURCE_DIR}
01103             )
01104             SET(builddir 
01105                 ${CMAKE_CURRENT_BINARY_DIR}
01106             )
01107             SET(datadir
01108                 ${CMAKE_INSTALL_PREFIX}/share
01109             )
01110             SET(docdir 
01111                 ${datadir}/doc/salome
01112             )
01113             ''')
01114             self.files.append("static/header.html.in")
01115         elif self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc') or mod in ['kernel', 'gui', 'geom', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui':
01116             newlines.append(r'''
01117             SET(top_builddir
01118                 ${CMAKE_BINARY_DIR}
01119             )
01120             SET(top_srcdir 
01121                 ${CMAKE_SOURCE_DIR}
01122             )
01123             SET(srcdir 
01124                 ${CMAKE_CURRENT_SOURCE_DIR}
01125             )
01126             SET(builddir 
01127                 ${CMAKE_CURRENT_BINARY_DIR}
01128             )
01129             SET(datadir
01130                 ${CMAKE_INSTALL_PREFIX}/share
01131             )
01132             SET(docdir 
01133                 ${datadir}/doc/salome
01134             )
01135             ''')
01136             self.files.append("static/header.html.in")
01137             if mod in ['geom', 'smesh', 'visu','netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin',"ghs3dprlplugin"] and self.root[-len(mod):] == upmod:
01138               self.files.append("static/header_py.html.in")
01139      
01140         if self.module == "yacs":
01141             key = "salomegui"
01142             if self.root[-len(key):] == key:
01143                 self.files.append("resources/YACSCatalog.xml.in")
01144                 self.files.append("resources/SalomeApp.xml.in")
01145                 pass
01146             pass
01147             from os import path
01148             if operator.contains(self.root, 'YACS_SRC'+path.sep+'doc'):
01149                 newlines.append(r'''
01150                 SET(srcdir 
01151                   ${CMAKE_CURRENT_SOURCE_DIR}
01152                 )
01153                 ''')
01154             
01155         if self.module == "jobmanager":
01156             key = "salomegui"
01157             if self.root[-len(key):] == key:
01158                 self.files.append("resources/SalomeApp.xml.in")
01159                 pass
01160             pass
01161         for f in self.files:
01162             if f[-3:] == ".in":
01163                 if self.module == 'yacs' and f == "Doxyfile.in":
01164                     continue
01165                 if f == "sstream.in":
01166                     continue
01167                 if f in ["runContainer.in", "stopContainer.in"]:
01168                     if self.module == "med":
01169                         if self.root[-3:] == "csh":
01170                             continue
01171                         pass
01172                     pass
01173                 if f == "SALOMEconfig.ref.in":
01174                     out = "SALOMEconfig.h"
01175                 else:
01176                     out = f[:-3]
01177                     pass
01178                 newlines.append(r'''
01179                 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/%s)
01180                 '''%(f))
01181                 newlines.append(r'''
01182                 SET(output ${CMAKE_CURRENT_BINARY_DIR}/%s)
01183                 '''%(out))
01184                 newlines.append(r'''
01185                 MESSAGE(STATUS "Creation of ${output}")
01186                 CONFIGURE_FILE(${input} ${output})
01187                 ''')
01188                 pass
01189             pass
01190 
01191         # --
01192         # add commands for generating of user's documentation
01193         # --
01194         doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/%s"%(upmod)
01195         doc_tui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s"%(upmod)
01196         doc_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome"
01197         head_source = "${CMAKE_CURRENT_SOURCE_DIR}/images/head.png"
01198         if mod == 'kernel':
01199             prepare_generating_doc_src = "${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/prepare_generating_doc.py"
01200         else:
01201             prepare_generating_doc_src = "$ENV{KERNEL_ROOT_DIR}/bin/salome/prepare_generating_doc.py"
01202         if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'):
01203             if mod == 'med':
01204                 doc_source = "${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html"
01205                 input = "Doxyfile_med_user"
01206             else:
01207                 doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01208                 input = ""
01209             newlines.append("""\t    ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s
01210             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')"
01211             VERBATIM 
01212             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01213             )"""%(input, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination))
01214         from os import path
01215         if mod in ['geom', 'smesh', 'visu', 'netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin','ghs3dprlplugin'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'):
01216             ign = r"""'*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'"""
01217             if mod in ['geom', 'smesh']:
01218                 if mod == 'geom':
01219                     tmp = 'geompy'
01220                     input = "COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_tui \n\t\t"
01221                 else:
01222                     tmp =  'smesh' 
01223                     input = ''
01224                 newlines.append(r"""
01225                 IF(WINDOWS)
01226                   STRING(REPLACE "/" "\\" f "%s")
01227               ELSE(WINDOWS)
01228                 SET(f "%s")                   
01229                 ENDIF(WINDOWS)
01230                 ADD_CUSTOM_TARGET(usr_docs ${PYTHON_EXECUTABLE} ${f} %s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
01231                 %sCOMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py
01232                 COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01233                 COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''%s.py''')"
01234                 COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''', r'''%s''', ignore=shutil.ignore_patterns(%s)); shutil.copy(r'''%s''', r'''%s''')"
01235                 VERBATIM 
01236                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01237                 )"""%(prepare_generating_doc_src, prepare_generating_doc_src, tmp, upmod, tmp, tmp, input, tmp, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
01238             else:
01239                 config_f = ""
01240               if mod in ['netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin', "ghs3dprlplugin"] :
01241                     config_f = "doxyfile_py"
01242                 else:
01243                     config_f = "doxyfile_idl"
01244                 newlines.append("""\t    ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s
01245                 COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01246                 COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''',True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=shutil.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')"
01247                 VERBATIM 
01248                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
01249                 )"""%(config_f, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
01250         elif mod == 'yacs' and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'):
01251             from sys import platform
01252             params = '';
01253             if platform == "win32":
01254                 params = '-Q';
01255             newlines.append(r"""
01256             ADD_CUSTOM_TARGET(html_docs ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc -b html ${ALLSPHINXOPTS} html
01257             COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''%s''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''%s''')\"
01258             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(params, doc_gui_destination, doc_gui_destination))             
01259        elif mod in ['kernel', 'smesh', 'geom'] and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'+path.sep+'docutils'):
01260             from sys import platform
01261             params = ""
01262             ext = ""
01263             prf = ""
01264             if platform == "win32":
01265                 params = '-Q';
01266                 ext = "bat"
01267                 prf = "call"
01268             else:
01269                 ext = "sh"
01270                 prf = ". "
01271             doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s/docutils"%(upmod)
01272             scr = self.writeEnvScript(upmod)                   
01273             newlines.append(r"""
01274             IF(WINDOWS)
01275                STRING(REPLACE "/" "\\" SCR "%s")
01276            ELSE(WINDOWS)
01277                SET(SCR "%s")
01278             ENDIF(WINDOWS)
01279             FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s "${SCR}")
01280             ADD_CUSTOM_TARGET(html_docs %s ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s && ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc/docutils -W -b html ${ALLSPHINXOPTS} html
01281             COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''%s''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''%s''')\"
01282             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(scr,scr,ext,prf,ext,params, doc_gui_destination, doc_gui_destination))
01283 
01284 
01285 
01286 
01287   # --
01288   # add commands for generating of developer's documentation
01289   # --
01290   
01291         upmod = self.module.upper()
01292         if mod in ['kernel', 'gui', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui':
01293             if mod == 'kernel':
01294                 tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u
01295             COMMAND ${DOXYGEN_EXECUTABLE}
01296             COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_CURRENT_BINARY_DIR}/doxyfile.bak''')"  """
01297                 tmp1=""
01298             else: 
01299                 tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE}"""
01300                 if mod == 'visu':
01301                     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)
01302                 elif mod == 'smesh':
01303                     extra_srcdir = "${CMAKE_CURRENT_SOURCE_DIR}/extra"
01304                     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''')" 
01305             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)
01306                 else:
01307                     tmp1=""
01308             doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01309             newlines.append(tmp + """
01310             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """
01311             VERBATIM 
01312             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01313             )""")
01314         if mod == 'geom' and self.root[-len('tui'):] == 'tui':
01315             tmp = 'geompy'
01316             doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
01317             newlines.append(r"""
01318             IF(WINDOWS)
01319               STRING(REPLACE "/" "\\" f "%s")
01320             ELSE(WINDOWS)
01321               SET(f "%s")
01322            ENDIF(WINDOWS)
01323             ADD_CUSTOM_TARGET(dev_docs ${PYTHON_EXECUTABLE} ${f} ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
01324             COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
01325             COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py''')"
01326             COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/geomscreen.png''', r'''%s''')"
01327             VERBATIM 
01328             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}             
01329             )"""%(prepare_generating_doc_src, prepare_generating_doc_src, upmod, tmp, upmod, tmp, tmp, upmod, tmp, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination, doc_tui_destination))
01330 
01331         # --
01332         # convert the SUBDIRS in cmake grammar
01333         # --
01334         if 1: # self.__thedict__.has_key("SUBDIRS"):
01335             newlines.append(r'''
01336             FOREACH(dir ${SUBDIRS})
01337             IF(NOT dir STREQUAL .)
01338             ADD_SUBDIRECTORY(${dir})
01339             ENDIF(NOT dir STREQUAL .)
01340             ENDFOREACH(dir ${SUBDIRS})
01341             ''')
01342             pass
01343         
01344         # --
01345         # --
01346         for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES", "libparaview_LTLIBRARIES"] :
01347             if self.__thedict__.has_key(key):
01348                 self.addLibTarget(key, newlines)
01349                 pass
01350             pass
01351         
01352         # --
01353         # --
01354         for key in ["bin_PROGRAMS", "check_PROGRAMS"]:
01355             if self.__thedict__.has_key(key):
01356                 self.addBinTarget(key, newlines)
01357                 pass
01358             pass
01359         
01360         # --
01361         # --
01362         if self.__thedict__.has_key("BASEIDL_FILES"):
01363             if not self.__thedict__.has_key("IDL_FILES"):
01364                 self.__thedict__["IDL_FILES"] = self.__thedict__["BASEIDL_FILES"]
01365                 newlines.append('''
01366                 SET(IDL_FILES ${BASEIDL_FILES})
01367                 ''')
01368                 pass
01369             pass
01370         
01371         # --
01372         # --
01373         
01374         key = "IDL_FILES"
01375         if self.__thedict__.has_key(key):
01376             if self.module == "kernel":
01377                 newlines.append('''
01378                 SET(IDL_FILES ${IDL_FILES} Calcium_Ports.idl)
01379                 ''')
01380                 pass
01381             newlines.append('''
01382             FOREACH(input ${IDL_FILES})
01383             STRING(REGEX REPLACE ".idl" "" base ${input})
01384             SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc)
01385             SET(outputs ${src})
01386             SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc)
01387             SET(outputs ${outputs} ${dynsrc})
01388             SET(inc ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
01389             SET(outputs ${outputs} ${inc})
01390             IF(input STREQUAL Calcium_Ports.idl)
01391             SET(input ${CMAKE_CURRENT_BINARY_DIR}/${input})
01392             ELSE(input STREQUAL Calcium_Ports.idl)
01393             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01394             ENDIF(input STREQUAL Calcium_Ports.idl)
01395             SET(flags ${IDLCXXFLAGS} ${OMNIORB_IDLCXXFLAGS})
01396             STRING(REGEX MATCH "-bcxx" ISBCXX ${flags})
01397             IF(NOT ISBCXX)
01398             SET(flags -bcxx ${flags})
01399             ENDIF(NOT ISBCXX)
01400             ADD_CUSTOM_COMMAND(
01401             OUTPUT ${outputs}
01402             COMMAND ${OMNIORB_IDL} ${flags} ${input}
01403             MAIN_DEPENDENCY ${input}
01404             )
01405             ''')
01406             newlines.append('''
01407             install(FILES ${input} DESTINATION idl/salome)
01408             ''')
01409             if self.module not in ["pyhello"]:
01410                 newlines.append('''
01411                 SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
01412                 install(FILES ${IDL_HEADER} DESTINATION include/salome)
01413                 ''')
01414                 pass
01415             newlines.append('''
01416             INSTALL(CODE "SET(IDL_FILE ${input})")
01417             INSTALL(CODE "SET(DIR ${salomepythondir})")
01418             IF(WINDOWS)
01419             INSTALL(CODE "SET(DIR bin/salome)")
01420             ENDIF(WINDOWS)
01421             INSTALL(CODE "SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})")
01422             INSTALL(CODE "SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL_PYTHON})")
01423             # --
01424             SET(flags)
01425             FOREACH(f ${IDLPYFLAGS})
01426             SET(flags "${flags} ${f}")
01427             ENDFOREACH(f ${IDLPYFLAGS})
01428             STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags})
01429             IF(NOT ISBPYTHON)
01430             SET(flags "-bpython ${flags}")
01431             ENDIF(NOT ISBPYTHON)
01432             SET(IDLPYFLAGS ${flags})
01433             STRING(REPLACE "\\\\" "/" IDLPYFLAGS ${IDLPYFLAGS})
01434             INSTALL(CODE "SET(IDLPYFLAGS ${IDLPYFLAGS})")
01435             # --
01436             ''')
01437             if self.module == "kernel":
01438                 newlines.append('''
01439                 INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
01440                 ''')
01441             else:
01442                 newlines.append('''
01443                 STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
01444                 INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
01445                 ''')
01446                 pass
01447             newlines.append('''
01448             ENDFOREACH(input ${IDL_FILES})
01449             ''')
01450             pass
01451         
01452         # --
01453         # --
01454         for key in ["SWIG_SRC", "SWIGSOURCES", "SWIG_DEF"]:
01455             if self.__thedict__.has_key(key):
01456                 newlines.append('''
01457                 SET(SWIG_SOURCES ${%s})
01458                 '''%(key))
01459                 self.__thedict__["SWIG_SOURCES"] = self.__thedict__[key]
01460                 pass
01461             pass
01462         
01463         # --
01464         # --
01465         if self.__thedict__.has_key("SWIG_SOURCES"):
01466             newlines.append('''
01467             IF(SWIG_SOURCES MATCHES ";")
01468             STRING(REGEX REPLACE ";.*" "" SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
01469             ELSE(SWIG_SOURCES MATCHES ";")
01470             SET(SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
01471             ENDIF(SWIG_SOURCES MATCHES ";")
01472             SET(flags)
01473             FOREACH(f ${SWIG_FLAGS} ${MY_SWIG_FLAGS})
01474             SET(test ON)
01475             IF(flags)
01476             LIST(FIND flags ${f} index)
01477             IF(NOT index EQUAL -1)
01478             SET(test OFF)
01479             ENDIF(NOT index EQUAL -1)
01480             ENDIF(flags)
01481             IF(test)
01482             SET(flags ${flags} ${f})
01483             ENDIF(test)
01484             ENDFOREACH(f ${SWIG_FLAGS} ${MY_SWIG_FLAGS})
01485             ADD_CUSTOM_COMMAND(
01486             OUTPUT ${build_srcs}
01487             COMMAND ${SWIG_EXECUTABLE} ${flags} -o ${build_srcs} ${CMAKE_CURRENT_SOURCE_DIR}/${SWIG_SOURCES_FIRST}
01488             MAIN_DEPENDENCY ${SWIG_SOURCES}
01489             )
01490             ''')
01491             pass
01492         
01493         # --
01494         # --
01495         if self.__thedict__.has_key("BUILT_SOURCES"):
01496             newlines.append('''
01497             FOREACH(f ${BUILT_SOURCES})
01498             IF(f MATCHES "WRAP.cxx$")
01499             # STRING(REGEX REPLACE "WRAP.cxx" "WRAP.h" inc ${f})
01500             STRING(REGEX REPLACE "WRAP.cxx" ".i" input ${f})
01501             ADD_CUSTOM_COMMAND(
01502             OUTPUT ${f} # ${inc}
01503             COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${SWIG_PYTHON_INCLUDES} ${MYSWIG_FLAGS} -o ${f} ${CMAKE_CURRENT_SOURCE_DIR}/${input}
01504             MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${input}
01505             )
01506             ENDIF(f MATCHES "WRAP.cxx$")
01507             ENDFOREACH(f ${BUILT_SOURCES})
01508             ''')
01509             pass
01510 
01511         # --
01512         # --
01513         key = "MOC_FILES"
01514         if self.__thedict__.has_key(key):
01515             newlines.append('''
01516             FOREACH(output ${MOC_FILES})
01517             ''')
01518             if self.module in ["jobmanager", "yacs"]:
01519                 newlines.append('''
01520                 STRING(REGEX REPLACE _moc.cxx .hxx input ${output})
01521                 ''')
01522             else:
01523                 newlines.append('''
01524                 STRING(REGEX REPLACE _moc.cxx .h input ${output})
01525                 ''')
01526                 pass
01527             newlines.append('''
01528             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01529             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01530             ADD_CUSTOM_COMMAND(
01531             OUTPUT ${output}
01532             COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input} -o ${output}
01533             MAIN_DEPENDENCY ${input}
01534             )
01535             ENDFOREACH(output ${MOC_FILES})
01536             ''')
01537             pass
01538         
01539         # --
01540         # --
01541         key = "MOC_FILES_HXX"
01542         if self.__thedict__.has_key(key):
01543             newlines.append('''
01544             FOREACH(output ${MOC_FILES_HXX})
01545             ''')
01546             newlines.append('''
01547             STRING(REGEX REPLACE _moc.cxx .hxx input ${output})
01548             ''')
01549             newlines.append('''
01550             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01551             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01552             ADD_CUSTOM_COMMAND(
01553             OUTPUT ${output}
01554             COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input} -o ${output}
01555             MAIN_DEPENDENCY ${input}
01556             )
01557             ENDFOREACH(output ${MOC_FILES_HXX})
01558             ''')
01559             pass
01560         
01561         # --
01562         # --
01563         key = "UIC_FILES"
01564         if self.__thedict__.has_key(key):
01565             newlines.append('''
01566             FOREACH(output ${UIC_FILES})
01567             STRING(REPLACE "ui_" "" input ${output})
01568             STRING(REPLACE ".h" ".ui" input ${input})
01569             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01570             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01571             ADD_CUSTOM_COMMAND(
01572             OUTPUT ${output}
01573             COMMAND ${QT_UIC_EXECUTABLE} -o ${output} ${input}
01574             MAIN_DEPENDENCY ${input}
01575             )
01576             ENDFOREACH(output ${UIC_FILES})
01577             ''')
01578             pass
01579         
01580         # --
01581         # --
01582         key = "PYUIC_FILES"
01583         if self.__thedict__.has_key(key):
01584             newlines.append('''
01585             FOREACH(output ${PYUIC_FILES})
01586             STRING(REPLACE "_ui.py" ".ui" input ${output})
01587             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01588             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01589             ADD_CUSTOM_COMMAND(
01590             OUTPUT ${output}
01591             COMMAND ${PYUIC_EXECUTABLE} -o ${output} ${input}
01592             MAIN_DEPENDENCY ${input}
01593             )
01594             ENDFOREACH(output ${PYUIC_FILES})
01595             ADD_CUSTOM_TARGET(BUILD_PY_UI_FILES ALL DEPENDS ${PYUIC_FILES})
01596             ''')
01597             pass
01598         
01599         # --
01600         # --
01601         key = "QRC_FILES"
01602         if self.__thedict__.has_key(key):
01603             newlines.append('''
01604             FOREACH(output ${QRC_FILES})
01605             STRING(REGEX REPLACE "qrc_" "" input ${output})
01606             STRING(REGEX REPLACE ".cxx" ".qrc" input ${input})
01607             STRING(REGEX REPLACE ".qrc" "" name ${input})
01608             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01609             SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
01610             ADD_CUSTOM_COMMAND(
01611             OUTPUT ${output}
01612             COMMAND ${QT_RCC_EXECUTABLE} ${input} -o ${output} -name ${name}
01613             MAIN_DEPENDENCY ${input}
01614             )
01615             ENDFOREACH(output ${QRC_FILES})
01616             ''')
01617             pass
01618         
01619         # --
01620         # --
01621         key = "SIP_FILES"
01622         if self.__thedict__.has_key(key):
01623             newlines.append('''
01624             FOREACH(input ${SIP_FILES})
01625             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01626             SET(output)
01627             FOREACH(out ${SIP_SRC})
01628             SET(output ${output} ${CMAKE_CURRENT_BINARY_DIR}/${out})
01629             ENDFOREACH(out ${SIP_SRC})
01630             ADD_CUSTOM_COMMAND(
01631             OUTPUT ${output}
01632             COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${input}
01633             MAIN_DEPENDENCY ${input}
01634             )
01635             ENDFOREACH(input ${SIP_FILES})
01636             ''')
01637             pass
01638 
01639         # --
01640         # For GUI/tools/dlgfactory
01641         # --
01642         key = "UIC_FILES_QDIALOG"
01643         if self.__thedict__.has_key(key):
01644             newlines.append('''
01645             FOREACH(output ${UIC_FILES_QDIALOG} ${UIC_FILES_GDIALOG})
01646             STRING(REPLACE "ui_" "" input ${output})
01647             STRING(REPLACE ".hxx" ".ui" input ${input})
01648             SET(input_path ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01649             IF (NOT EXISTS ${input_path})
01650               SET(input_path ${CMAKE_CURRENT_BINARY_DIR}/${input})
01651             ENDIF (NOT EXISTS ${input_path})
01652             ADD_CUSTOM_COMMAND(
01653             OUTPUT ${output}
01654             COMMAND ${QT_UIC_EXECUTABLE} -o ${output} ${input_path}
01655             MAIN_DEPENDENCY ${input}
01656             )
01657             ENDFOREACH(output ${UIC_FILES})
01658 
01659             FOREACH(output ${MOC_FILES_QDIALOG} ${MOC_FILES_GDIALOG})
01660             STRING(REGEX REPLACE _moc.cxx .hxx input ${output})
01661             SET(input_path ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01662             IF (NOT EXISTS ${input_path})
01663               SET(input_path ${CMAKE_CURRENT_BINARY_DIR}/${input})
01664             ENDIF (NOT EXISTS ${input_path})
01665             ADD_CUSTOM_COMMAND(
01666             OUTPUT ${output}
01667             COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input_path} -o ${output}
01668             MAIN_DEPENDENCY ${input}
01669             )
01670             ENDFOREACH(output ${MOC_FILES})
01671             
01672             ADD_CUSTOM_COMMAND(
01673             OUTPUT QDialogTest.ui QDialogTest.hxx QDialogTest.cxx
01674             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.py -n QDialogTest -t qdialog
01675             DEPENDS __QDIALOG__.ui __QDIALOG__.hxx __QDIALOG__.cxx dlgfactory.py
01676             )
01677             
01678             ADD_CUSTOM_COMMAND(
01679             OUTPUT GDialogTest.ui GDialogTest.hxx GDialogTest.cxx
01680             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.py -n GDialogTest -t gdialog
01681             DEPENDS __GDIALOG__.ui __GDIALOG__.hxx __GDIALOG__.cxx dlgfactory.py
01682             )
01683             ''')
01684             pass
01685 
01686         # --
01687         # For make check
01688         # --
01689         for key in ["TESTS"]:
01690             if self.__thedict__.has_key(key):
01691                 newlines.append('''
01692                 SET(UNIT_TEST_PROG ${%s})
01693                 '''%(key))
01694                 self.__thedict__["UNIT_TEST_PROG"] = self.__thedict__[key]
01695                 pass
01696             pass
01697         key = "UNIT_TEST_PROG"
01698         if self.__thedict__.has_key(key):
01699             newlines.append('''
01700             FOREACH(input ${UNIT_TEST_PROG})
01701             GET_FILENAME_COMPONENT(ext ${input} EXT)
01702             IF(ext STREQUAL .py)
01703             SET(test ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${input})
01704             ELSE(ext STREQUAL .py)
01705             IF(WINDOWS)
01706             SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe.exe)
01707             ELSE()
01708             SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe)
01709             ENDIF()
01710             ENDIF(ext STREQUAL .py)
01711             ADD_TEST(${input} ${test})
01712             SET(fail_regex "KO")
01713             SET_PROPERTY(TEST ${input} PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}")
01714             # IF(NOT WINDOWS)
01715             # ADD_TEST(${input}_valgrind valgrind ${test})
01716             # SET_PROPERTY(TEST ${input}_valgrind PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}")
01717             # SET_PROPERTY(TEST ${input}_valgrind PROPERTY PASS_REGULAR_EXPRESSION "no leaks are possible")
01718             # ENDIF()
01719             ENDFOREACH(input ${UNIT_TEST_PROG})
01720             ''')
01721             pass
01722         
01723         # --
01724         # Treat the install targets
01725         # --
01726         resdir = self.module
01727         if resdir == "hxx2salome":
01728             resdir = self.hxxmodule
01729             pass
01730         d = {
01731             "salomeadmux_DATA"                 :  "salome_adm/unix",
01732             "dist_salomeadmux_DATA"            :  "salome_adm/unix",
01733             "dist_salome_cmake_DATA"           :  "salome_adm/cmake_files",
01734             "dist_salomem4_DATA"               :  "salome_adm/unix/config_files",
01735             "dist_salome4depr_DATA"            :  "salome_adm/unix/config_files/DEPRECATED",
01736             "dist_admlocalm4_DATA"             :  "adm_local/unix/config_files",
01737             "dist_admlocal_cmake_DATA"         :  "adm_local/cmake_files",
01738             "salomeinclude_DATA"               :  "include/salome",
01739             "salomeinclude_HEADERS"            :  "include/salome",
01740             "nodist_salomeinclude_HEADERS"     :  "include/salome",
01741             "dist_salomeres_DATA"              :  "share/salome/resources/%s"%(resdir),
01742             "nodist_salomeres_DATA"            :  "share/salome/resources/%s"%(resdir),
01743             "nodist_salomeres_SCRIPTS"         :  "share/salome/resources/%s"%(resdir),
01744             "dist_salomescript_SCRIPTS"        :  "bin/salome",
01745             "dist_salomescript_DATA"           :  "bin/salome",
01746             "dist_salomescript_PYTHON"         :  "bin/salome",
01747             "dist_appliskel_SCRIPTS"           :  "bin/salome/appliskel",
01748             "dist_appliskel_PYTHON"            :  "bin/salome/appliskel",
01749             "nodist_salomescript_DATA"         :  "bin/salome",
01750             "salomepython_PYTHON"              :  "${salomepythondir}",
01751             "nodist_salomepython_PYTHON"       :  "${salomepythondir}",
01752             "dist_salomepython_DATA"           :  "${salomepythondir}",
01753             "sharedpkgpython_PYTHON"           :  "${salomepythondir}/shared_modules",
01754             "salomepypkg_PYTHON"               :  "${salomepypkgdir}",
01755             "mypkgpython_PYTHON"               :  "${mypkgpythondir}",
01756             "nodist_mypkgpython_PYTHON"        :  "${mypkgpythondir}",
01757             }
01758         if self.module == "jobmanager":
01759             d["bin_SCRIPTS"] = "bin"
01760             pass
01761         if self.module == "medfile":
01762             d = {
01763                 "include_HEADERS"        :  "include",
01764                 "nodist_include_HEADERS" :  "include",
01765                 "bin_SCRIPTS"            :  "bin",
01766                 "doc_DATA"               :  "${docdir}",
01767                 }
01768             pass
01769         if self.module == "netgen":
01770             d = {
01771                 "include_HEADERS"        :  "include",
01772                 "noinst_HEADERS"         :  "share/netgen/include",
01773                 "dist_pkgdata_DATA"      :  "share/netgen",
01774                 "dist_doc_DATA"          :  "share/doc/netgen",
01775                 }
01776             pass
01777         for key, value in d.items():
01778             if self.__thedict__.has_key(key):
01779                 self.addInstallTarget(key, value, newlines)
01780                 pass
01781             pass
01782         
01783         # --
01784         return
01785     
01786     def setLibAdd(self, key, newlines):
01787         # --
01788         newlines.append(r'''
01789         SET(libadd)
01790         ''')
01791         # --
01792         newlines.append(r'''
01793         IF(WINDOWS)
01794         SET(targets)
01795         SET(targets ${targets} MEFISTO2D)
01796         FOREACH(target ${targets})
01797         IF(name STREQUAL ${target})
01798         SET(dir $ENV{F2CHOME})
01799         STRING(REPLACE "\\\\" "/" dir ${dir})
01800         SET(libadd ${libadd} ${dir}/LIBF77.lib)
01801         SET(libadd ${libadd} ${dir}/LIBI77.lib)
01802         ENDIF(name STREQUAL ${target})
01803         ENDFOREACH(target ${targets})
01804         ELSE(WINDOWS)
01805         SET(targets)
01806         SET(targets ${targets} MEFISTO2D)
01807         FOREACH(target ${targets})
01808         IF(name STREQUAL ${target})
01809         SET(libadd ${libadd} -lf2c)
01810         ENDIF(name STREQUAL ${target})
01811         ENDFOREACH(target ${targets})
01812         ENDIF(WINDOWS)
01813         ''')
01814         # --
01815         newlines.append(r'''
01816         SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${LDADD} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS})
01817         FOREACH(lib SALOMEBasics SalomeBatch)
01818         IF(name STREQUAL lib)
01819         SET(libs ${libs} ${PTHREAD_LIBS})
01820         ENDIF(name STREQUAL lib)
01821         ENDFOREACH(lib SALOMEBasics SalomeBatch)
01822         ''')
01823         # --
01824         newlines.append(r'''
01825         FOREACH(lib ${libs})
01826         GET_FILENAME_COMPONENT(ext ${lib} EXT)
01827         IF(ext STREQUAL .la)
01828         GET_FILENAME_COMPONENT(lib ${lib} NAME_WE)
01829         STRING(REGEX REPLACE "^lib" "" lib ${lib})
01830         ENDIF(ext STREQUAL .la)
01831         SET(vars)
01832         SET(vars ${vars} -no-undefined)
01833         SET(vars ${vars} -lvtkWidgets)
01834         IF(WINDOWS)
01835         SET(vars ${vars} -module)
01836         SET(vars ${vars} -Wl,-E)
01837         SET(vars ${vars} -Xlinker)
01838         SET(vars ${vars} -export-dynamic)
01839         SET(vars ${vars} -lm)
01840         SET(vars ${vars} -lboost_thread)
01841         SET(vars ${vars} -lboost_signals)
01842         SET(vars ${vars} -pthread -lpthread -ldl)
01843         ENDIF(WINDOWS)
01844         FOREACH(v ${vars})
01845         IF(lib STREQUAL v)
01846         SET(lib)
01847         ENDIF(lib STREQUAL v)
01848         ENDFOREACH(v ${vars})
01849         SET(test OFF)
01850         IF(lib)
01851         STRING(REGEX MATCH "^-lQt" test ${lib})
01852         ENDIF(lib)
01853         IF(NOT test)
01854         SET(libadd ${libadd} ${lib})
01855         ENDIF(NOT test)
01856         ENDFOREACH(lib ${libs})
01857         TARGET_LINK_LIBRARIES(${name} ${libadd})
01858         ''')
01859         # --
01860         newlines.append(r'''
01861         IF(WINDOWS)
01862         SET(targets)
01863         SET(targets ${targets} MEFISTO2D)
01864         FOREACH(target ${targets})
01865         IF(name STREQUAL ${target})
01866         IF(CMAKE_BUILD_TYPE STREQUAL Debug)
01867         SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
01868         ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
01869         ENDIF(name STREQUAL ${target})
01870         ENDFOREACH(target ${targets})
01871         ENDIF(WINDOWS)
01872         ''')
01873         # --
01874         return
01875     
01876     def setCompilationFlags(self, key, newlines):
01877         newlines.append(r'''
01878         SET(var)
01879         IF(WINDOWS)
01880         SET(targets)
01881         SET(targets ${targets} SalomeIDLKernel)
01882         SET(targets ${targets} SalomeDS)
01883         SET(targets ${targets} SALOMEDSTest)
01884         SET(targets ${targets} SALOMEDS_Client_exe)
01885         SET(targets ${targets} SalomeIDLGEOM)
01886         SET(targets ${targets} GEOMEngine)
01887         SET(targets ${targets} MEDEngine)
01888         SET(targets ${targets} SMESHEngine)
01889         SET(targets ${targets} SMESH)
01890         SET(targets ${targets} SalomeIDLSPADDER)
01891         SET(targets ${targets} MeshJobManagerEngine)
01892         SET(targets ${targets} StdMeshersEngine)
01893         SET(targets ${targets} VISUEngineImpl)
01894         FOREACH(target ${targets})
01895         IF(name STREQUAL ${target})
01896         SET(var ${var} -DNOGDI)
01897         ENDIF(name STREQUAL ${target})
01898         ENDFOREACH(target ${targets})
01899         ENDIF(WINDOWS)
01900         ''')
01901         # --
01902         if self.module in ["medfile", "yacs"]:
01903             newlines.append(r'''
01904             IF(WINDOWS)
01905             SET(var ${var} -DNOGDI)
01906             ENDIF(WINDOWS)
01907             ''')
01908             pass
01909         # --
01910         newlines.append(r'''
01911         IF(WINDOWS)
01912         SET(targets)
01913         SET(targets ${targets} MEFISTO2D)
01914         FOREACH(target ${targets})
01915         IF(name STREQUAL ${target})
01916         SET(dir $ENV{F2CHOME})
01917         STRING(REPLACE "\\\\" "/" dir ${dir})
01918         SET(var ${var} -I${dir})
01919         SET(var ${var} -DF2C_BUILD)
01920         ENDIF(name STREQUAL ${target})
01921         ENDFOREACH(target ${targets})
01922         ENDIF(WINDOWS)
01923         ''')
01924         # --
01925         if self.module in ["geom", "med"]:
01926             newlines.append(r'''
01927             SET(var ${var} -I${CMAKE_CURRENT_SOURCE_DIR})
01928             SET(var ${var} -I${CMAKE_CURRENT_BINARY_DIR})
01929             ''')
01930             pass
01931         newlines.append(r'''
01932         SET(var ${var} ${AM_CPPFLAGS})
01933         SET(var ${var} ${AM_CXXFLAGS})
01934         ''')
01935         # --
01936         newlines.append(r'''
01937         IF(type STREQUAL STATIC)
01938         SET(var ${var} -fPIC)
01939         ENDIF(type STREQUAL STATIC)
01940         ''')
01941         # --
01942         if self.module == "yacs":
01943             newlines.append(r'''
01944             SET(var ${var} -DYACS_PTHREAD)
01945             SET(var ${var} -DCMAKE_BUILD)
01946             SET(var ${var} -DSALOME_KERNEL)
01947             SET(var ${var} -DDSC_PORTS)
01948             SET(var ${var} -DOMNIORB)
01949             ''')
01950             pass
01951         newlines.append(r'''
01952   SET(var ${var} ${PLATFORM_CPPFLAGS})
01953   SET(var ${var} ${PTHREAD_CFLAGS})
01954   SET(var ${var} ${${amname}_CPPFLAGS})
01955   SET(var ${var} ${${amname}_CXXFLAGS})
01956   SET(var ${var} ${${amname}_CFLAGS})
01957         SET(vars)
01958         IF(WINDOWS)
01959         SET(vars ${vars} -include SALOMEconfig.h)
01960         SET(vars ${vars} -ftemplate-depth-32)
01961         SET(vars ${vars} -fPIC)
01962         SET(vars ${vars} -g)
01963         ENDIF(WINDOWS)
01964         SET(flags)
01965         FOREACH(f ${var})
01966         FOREACH(v ${vars})
01967         IF(f STREQUAL v)
01968         SET(f)
01969         ENDIF(f STREQUAL v)
01970         ENDFOREACH(v ${vars})
01971         IF(f)
01972         string(REGEX MATCH "^-I" test_include ${f})
01973         if(test_include)
01974         string(REGEX REPLACE "^-I" "" include_dir ${f})
01975         if(include_dir)
01976         if(include_dir STREQUAL /usr/include)
01977         else(include_dir STREQUAL /usr/include)
01978         string(REGEX MATCH "^\\." test_dot ${include_dir})
01979         if(test_dot)
01980         set(include_dir ${CMAKE_CURRENT_BINARY_DIR}/${include_dir})
01981         endif(test_dot)
01982         include_directories(${include_dir})
01983         endif(include_dir STREQUAL /usr/include)
01984         endif(include_dir)
01985         else(test_include)
01986         SET(flags "${flags} ${f}")
01987         endif(test_include)
01988         ENDIF(f)
01989         ENDFOREACH(f ${var})
01990         SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}")
01991         ''')
01992         return
01993     
01994     def addLibTarget(self, key, newlines):
01995         newlines.append(r'''
01996         FOREACH(amname ${%s})
01997         '''%(key))
01998         # --
01999         # Replace .la by _la ...
02000         # --
02001         newlines.append(r'''
02002         STRING(REPLACE .la _la amname ${amname})
02003         ''')
02004         # --
02005         # Remove the _la for the cmake name
02006         # --
02007         newlines.append(r'''
02008         STRING(LENGTH ${amname} len)
02009         MATH(EXPR newlen "${len}-3")
02010         STRING(SUBSTRING ${amname} 0 ${newlen} name)
02011         ''')
02012         # --
02013         # Does the target begins with lib ??
02014         # If yes, remove lib at beginning for cmake name
02015         # --
02016         newlines.append(r'''
02017         STRING(REGEX MATCH "^lib" BEGIN_WITH_lib ${name})
02018         IF(BEGIN_WITH_lib)
02019         STRING(LENGTH ${name} len)
02020         MATH(EXPR newlen "${len}-3")
02021         STRING(SUBSTRING ${name} 3 ${newlen} name)
02022         ENDIF(BEGIN_WITH_lib)
02023         ''')
02024         # --
02025         # Does the target is an idl library
02026         # --
02027         newlines.append(r'''
02028         STRING(REGEX MATCH "IDL" ISIDL ${name})
02029         ''')
02030         # --
02031         # Set the type of the library
02032         # --
02033         newlines.append(r'''
02034         IF(ISIDL)
02035         IF(WINDOWS)
02036         SET(type STATIC)
02037         ELSE(WINDOWS)
02038         SET(type SHARED)
02039         ENDIF(WINDOWS)
02040         ELSE(ISIDL)
02041         SET(type SHARED)
02042         ENDIF(ISIDL)
02043         ''')
02044         if key == "noinst_LTLIBRARIES":
02045             newlines.append(r'''
02046             IF(WINDOWS)
02047             SET(type STATIC)
02048             ELSE(WINDOWS)
02049             SET(type STATIC)
02050             ENDIF(WINDOWS)
02051             ''')
02052             pass
02053         # --
02054         # Set sources for the library
02055         # --
02056         newlines.append(r'''
02057         SET(srcs)
02058         FOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
02059         GET_FILENAME_COMPONENT(ext ${src} EXT)
02060         IF(ext STREQUAL .f)
02061         IF(src STREQUAL trte.f)
02062         SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
02063         STRING(REPLACE ".f" ".c" src ${src})
02064         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
02065         SET(output ${src})
02066         SET(cmd f2c)
02067         IF(NOT WINDOWS)
02068         IF(CMAKE_SIZEOF_VOID_P STREQUAL 8)
02069         SET(cmd valgrind f2c)  # f2c seems to be buggy on 64 bits ... but with valgrind, it works :)
02070         ENDIF()
02071         ENDIF(NOT WINDOWS)
02072         ADD_CUSTOM_COMMAND(
02073         OUTPUT ${output}
02074         COMMAND ${cmd} ${input}
02075         MAIN_DEPENDENCY ${input}
02076         )
02077         ELSE(src STREQUAL trte.f)
02078         SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
02079         STRING(REPLACE ".f" ".o" src ${src})
02080         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
02081         SET(output ${src})
02082         IF(WINDOWS)
02083         SET(F77 g77)
02084         ELSE(WINDOWS)
02085         SET(F77 gfortran)
02086         ENDIF(WINDOWS)
02087         ADD_CUSTOM_COMMAND(
02088         OUTPUT ${output}
02089         COMMAND ${F77} -c -o ${output} ${input}
02090         MAIN_DEPENDENCY ${input}
02091         )
02092         ENDIF(src STREQUAL trte.f)
02093         ENDIF(ext STREQUAL .f)
02094         SET(srcs ${srcs} ${src})
02095         ENDFOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
02096         ''')
02097         newlines.append(r'''
02098         SET(l ${nodist_${amname}_SOURCES} ${UIC_FILES})
02099         FOREACH(f ${l})
02100         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${f})
02101         SET(srcs ${srcs} ${src})
02102         ENDFOREACH(f ${l})
02103         ''')
02104         newlines.append(r'''
02105         SET(build_srcs)
02106         SET(l ${nodist_${amname}_SOURCES} ${BUILT_SOURCES})
02107         FOREACH(f ${l})
02108         GET_FILENAME_COMPONENT(ext ${f} EXT)
02109         IF(ext STREQUAL .py)
02110         SET(fff)
02111         ELSE(ext STREQUAL .py)
02112         SET(fff ${CMAKE_CURRENT_BINARY_DIR}/${f})
02113         ENDIF(ext STREQUAL .py)
02114         IF(fff)
02115         IF(build_srcs)
02116         LIST(FIND build_srcs ${fff} index)
02117         IF(NOT index EQUAL -1)
02118         SET(fff)
02119         ENDIF(NOT index EQUAL -1)
02120         ENDIF(build_srcs)
02121         ENDIF(fff)
02122         IF(fff)
02123         SET(build_srcs ${build_srcs} ${fff})
02124         ENDIF(fff)
02125         ENDFOREACH(f ${l})
02126         ''')
02127         # --
02128         # Add the library to cmake
02129         # --
02130         newlines.append(r'''
02131         ADD_LIBRARY(${name} ${type} ${srcs})
02132         ''')
02133         # --
02134         # The compilation flags
02135         # --
02136         self.setCompilationFlags(key, newlines)
02137         # --
02138         newlines.append(r'''
02139         SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${VERSION_INFO} SOVERSION ${SOVERSION_INFO})
02140         ''')
02141         # --
02142         self.setLibAdd(key, newlines)
02143         # --
02144         if 1: # key != "noinst_LTLIBRARIES":
02145             newlines.append(r'''
02146             SET(key %s)
02147             '''%(key))
02148             newlines.append(r'''
02149             SET(test ON)
02150             IF(${key} STREQUAL noinst_LTLIBRARIES)
02151             SET(test OFF)
02152             ENDIF(${key} STREQUAL noinst_LTLIBRARIES)
02153             ''')
02154             if self.module == "netgen" :
02155                 newlines.append(r'''
02156                 IF(${key} STREQUAL noinst_LTLIBRARIES)
02157                 IF(WINDOWS)
02158                 SET(test ON)
02159                 ENDIF(WINDOWS)
02160                 ENDIF(${key} STREQUAL noinst_LTLIBRARIES)
02161                 ''')
02162                 pass
02163             newlines.append(r'''
02164             IF(test)
02165             ''')
02166             if self.module in ["medfile", "netgen"]:
02167                 newlines.append(r'''
02168                 SET(DEST lib)
02169                 ''')
02170             elif key == "libparaview_LTLIBRARIES":
02171                 newlines.append(r'''
02172                 SET(DEST lib/paraview)
02173                 ''')                
02174             else:
02175                 newlines.append(r'''
02176                 SET(DEST lib/salome)
02177                 ''')
02178                 pass
02179             newlines.append(r'''
02180             IF(BEGIN_WITH_lib)
02181             INSTALL(TARGETS ${name} DESTINATION ${DEST})
02182             ''')
02183             if self.module == "gui":
02184                 newlines.append(r'''
02185                 FOREACH(lib SalomePyQt)
02186                 IF(name STREQUAL lib)
02187                 IF(WINDOWS)
02188                 IF(CMAKE_BUILD_TYPE STREQUAL Release)
02189                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}.pyd)
02190                 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
02191                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}_d.pyd)
02192                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
02193                 ELSE(WINDOWS)
02194                 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION ${DEST} RENAME ${name}.so)
02195                 ENDIF(WINDOWS)
02196                 ENDIF(name STREQUAL lib)
02197                 ENDFOREACH(lib SalomePyQt)
02198                 FOREACH(lib SalomePy)
02199                 IF(name STREQUAL lib)
02200                 IF(WINDOWS)
02201                 IF(CMAKE_BUILD_TYPE STREQUAL Release)
02202                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.pyd)
02203                 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
02204                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}_d.pyd)
02205                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
02206                 ENDIF(WINDOWS)
02207                 ENDIF(name STREQUAL lib)
02208                 ENDFOREACH(lib SalomePy)
02209                 ''')
02210                 pass
02211             if self.module == "geom":
02212                 newlines.append(r'''
02213                 IF(WINDOWS)
02214                 STRING(REGEX MATCH "Export" ISExport ${name})
02215                 IF(ISExport)
02216                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
02217                 ENDIF(ISExport)
02218                 STRING(REGEX MATCH "Import" ISImport ${name})
02219                 IF(ISImport)
02220                 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
02221                 ENDIF(ISImport)
02222                 ENDIF(WINDOWS)
02223                 ''')
02224                 pass
02225             newlines.append(r'''
02226             ELSE(BEGIN_WITH_lib)
02227             ''')
02228             newlines.append(r'''
02229             IF(WINDOWS)
02230             INSTALL(TARGETS ${name} DESTINATION ${salomepythondir})
02231             IF(CMAKE_BUILD_TYPE STREQUAL Release)
02232             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}.pyd)
02233             ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
02234             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}_d.pyd)
02235             ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
02236             ELSE(WINDOWS)
02237             GET_TARGET_PROPERTY(version ${name} VERSION)
02238             GET_TARGET_PROPERTY(soversion ${name} SOVERSION)
02239             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${version})
02240             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${soversion})
02241             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so)
02242             ENDIF(WINDOWS)
02243             ''')
02244             newlines.append(r'''
02245             ENDIF(BEGIN_WITH_lib)
02246             ''')
02247             newlines.append(r'''
02248             ENDIF(test)
02249             ''')
02250             pass
02251         # --
02252         newlines.append(r'''
02253         ENDFOREACH(amname ${%s})
02254         '''%(key))
02255         # --
02256         return
02257     
02258     def addBinTarget(self, key, newlines):
02259         # --
02260         newlines.append(r'''
02261         FOREACH(amname ${%s})
02262         '''%(key))
02263         # --
02264         newlines.append(r'''
02265         SET(test ON)
02266         ''')
02267         if key == "check_PROGRAMS":
02268             newlines.append(r'''
02269             IF(bin_PROGRAMS)
02270             STRING(REGEX MATCH ${amname} is_present ${bin_PROGRAMS})
02271             IF(is_present)
02272             SET(test OFF)
02273             ENDIF(is_present)
02274             ENDIF(bin_PROGRAMS)
02275             ''')
02276             pass
02277         newlines.append(r'''
02278         IF(test)
02279         ''')
02280         # --
02281         newlines.append(r'''
02282         SET(name "${amname}_exe")
02283         SET(srcs ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
02284         SET(l ${nodist_${amname}_SOURCES})
02285         FOREACH(f ${l})
02286         SET(src ${CMAKE_CURRENT_BINARY_DIR}/${f})
02287         SET(srcs ${srcs} ${src})
02288         ENDFOREACH(f ${l})
02289         LIST(LENGTH srcs nb)
02290         IF(nb)
02291         ADD_EXECUTABLE(${name} ${srcs})
02292         ''')
02293         # --
02294         self.setCompilationFlags(key, newlines)
02295         # --
02296         self.setLibAdd(key, newlines)
02297         # --
02298         if self.module in ["jobmanager", "medfile", "netgen"]:
02299             newlines.append(r'''
02300             SET(DEST bin)
02301             ''')
02302         else:
02303             newlines.append(r'''
02304             SET(DEST bin/salome)
02305             ''')
02306             pass
02307         # --
02308         if key == "bin_PROGRAMS":
02309             newlines.append(r'''
02310             IF(WINDOWS)
02311             INSTALL(TARGETS ${name} DESTINATION ${DEST})
02312             INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe DESTINATION ${DEST} RENAME ${amname}.exe)
02313             INSTALL(CODE "FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe)")
02314             ELSE(WINDOWS)
02315             SET(PERMS)
02316             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02317             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02318             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02319             INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name} DESTINATION ${DEST} PERMISSIONS ${PERMS} RENAME ${amname})
02320             ENDIF(WINDOWS)
02321             ''')
02322             pass
02323         # --
02324         newlines.append(r'''
02325         ENDIF(nb)
02326         ''')
02327         # --
02328         newlines.append(r'''
02329         ENDIF(test)
02330         ''')
02331         newlines.append(r'''
02332         ENDFOREACH(amname ${%s})
02333         '''%(key))
02334         # --
02335         return
02336     
02337     def addInstallTarget(self, key, destination, newlines):
02338         newlines.append(r"FOREACH(f ${%s})"%(key))
02339         newlines.append(r'''
02340         SET(DEST %s)
02341         '''%(destination))
02342         newlines.append(r'''
02343         STRING(COMPARE EQUAL ${f} SALOMEconfig.h.in test_SALOMEconfig.h.in)
02344         IF(test_SALOMEconfig.h.in)
02345         INSTALL(FILES SALOMEconfig.ref.in DESTINATION ${DEST} RENAME SALOMEconfig.h.in)
02346         ELSE(test_SALOMEconfig.h.in)
02347         SET(dummy dummy-NOTFOUND)
02348         MARK_AS_ADVANCED(dummy)
02349         # FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${f})
02350         FIND_FILE(dummy ${f} PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
02351         IF(dummy)
02352         ''')
02353         if key in ['dist_salomescript_SCRIPTS',
02354                    'dist_appliskel_SCRIPTS',
02355                    'dist_appliskel_PYTHON']:
02356             newlines.append(r'''
02357             SET(PERMS)
02358             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02359             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02360             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02361             INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
02362             ''')
02363         else:
02364             newlines.append(r'''
02365             GET_FILENAME_COMPONENT(ext ${f} EXT)
02366             IF(ext STREQUAL .py)
02367             IF(DEST STREQUAL bin/salome)
02368             SET(PERMS)
02369             SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
02370             SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
02371             SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
02372             INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
02373             ELSE(DEST STREQUAL bin/salome)
02374             INSTALL(FILES ${f} DESTINATION ${DEST})
02375             ENDIF(DEST STREQUAL bin/salome)
02376             ELSE(ext STREQUAL .py)
02377             INSTALL(FILES ${f} DESTINATION ${DEST})
02378             ENDIF(ext STREQUAL .py)
02379             ''')
02380             pass
02381         newlines.append(r'''
02382         ELSE(dummy)
02383         GET_FILENAME_COMPONENT(ext ${f} EXT)
02384         IF(ext STREQUAL .qm)
02385         STRING(REGEX REPLACE .qm .ts input ${f})
02386         ''')
02387         if self.module in ["kernel", "gui", "yacs"]:
02388             newlines.append(r'''
02389             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/resources/${input})
02390             ''')
02391         else:
02392             newlines.append(r'''
02393             SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
02394             ''')
02395             pass
02396         newlines.append(r'''
02397         SET(output ${CMAKE_CURRENT_BINARY_DIR}/${f})
02398         # ADD_CUSTOM_COMMAND(
02399         # OUTPUT ${output}
02400         # COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output}
02401         # MAIN_DEPENDENCY ${input}
02402         # )
02403         EXECUTE_PROCESS(COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output})
02404         ENDIF(ext STREQUAL .qm)
02405         INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${DEST})
02406         ENDIF(dummy)
02407         ENDIF(test_SALOMEconfig.h.in)
02408         ''')
02409         newlines.append(r'''
02410         GET_FILENAME_COMPONENT(ext ${f} EXT)
02411         IF(ext STREQUAL .py)
02412         INSTALL(CODE "SET(PYTHON_FILE ${f})")
02413         INSTALL(CODE "SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})")
02414         INSTALL(CODE "SET(DEST ${DEST})")
02415         INSTALL(CODE "SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})")
02416         ''')
02417         if self.module == "kernel":
02418             newlines.append('''
02419             IF(f STREQUAL SALOME_ContainerPy.py)
02420             ELSE(f STREQUAL SALOME_ContainerPy.py)
02421             IF(f STREQUAL am2cmake.py)
02422             ELSE(f STREQUAL am2cmake.py)
02423             INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
02424             ENDIF(f STREQUAL am2cmake.py)
02425             ENDIF(f STREQUAL SALOME_ContainerPy.py)
02426             ''')
02427         else:
02428             newlines.append('''
02429             STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
02430             INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
02431             ''')
02432             pass
02433         newlines.append(r'''
02434         ENDIF(ext STREQUAL .py)
02435         ''') 
02436         newlines.append(r"ENDFOREACH(f ${%s})"%(key))
02437         return
02438     
02439     def writeListsFile(self):
02440         f = open(self.listsFile, "w")
02441         f.write(self.content)
02442         f.close()
02443         return
02444 
02445     def writeEnvScript(self, upmod):
02446         from sys import platform, version_info
02447         p_version = """%s.%s"""%(version_info[0],version_info[1])
02448         python_path ="PYTHONPATH"
02449         path = ""
02450         begin = ""
02451         end = ""
02452         delim = ""
02453         cmd = ""
02454         pdir = ""
02455         omni = ""
02456        omni_py = ""
02457         if platform == "win32" :          
02458             path = "PATH"
02459             begin = "%"
02460             end = "%"
02461             delim = ";"
02462             cmd = "@SET "
02463             omni = "/x86_win32"
02464             omni_py = "/python"
02465             pdir = "PDIR"
02466         else:
02467             path = "LD_LIBRARY_PATH"
02468             begin = "\${"
02469             end = "}"
02470             delim = ":"
02471             cmd = "export "
02472             omni_py = "/python" + p_version + "/" + "site-packages"
02473             pdir = "INST_ROOT"
02474 
02475             
02476         path_ = begin + path + end
02477         root_dir_ = begin + upmod + "_ROOT_DIR" + end  
02478         python_path_ = begin + python_path + end
02479         _python_path_ = delim + python_path_+ "\n"
02480         _path_ = delim + path_+ "\n" 
02481         _pdir = begin + pdir + end 
02482            
02483         
02484         script = cmd + " " + python_path + "=" + root_dir_+"/lib/python" + p_version \
02485         + "/site-packages/salome" + _python_path_ 
02486         
02487         script = script + cmd + " " + python_path + "=" + root_dir_+"/bin/salome" + \
02488         _python_path_
02489 
02490         script = script + cmd + " "+ path + "=" + root_dir_+"/lib/salome"+ _path_
02491 
02492        if upmod == "KERNEL" :
02493             script = script + cmd + " " +  python_path + "=" + _pdir + \
02494             "/omniORB-4.1.5/lib" + omni + _python_path_
02495         
02496             script = script + cmd + " " + python_path + "=" + _pdir + \
02497             "/omniORB-4.1.5/lib" + omni_py + _python_path_
02498         
02499             script = script + cmd + " "+ path + "=" + _pdir+ "/omniORB-4.1.5/lib" + \
02500             omni + _path_
02501 
02502         if upmod == "GEOM" :
02503             script = self.writeEnvScript("KERNEL") + script
02504             script = self.writeEnvScript("GUI") + script
02505 
02506         if upmod == "SMESH" :
02507             script = self.writeEnvScript("GEOM") + script
02508 
02509         return script    
02510     pass
02511 
02512 def convertAmFile(the_root, root, dirs, files, f, module):
02513     cmake = CMakeFile(the_root, root, dirs, files, f, module)
02514     cmake.writeListsFile()
02515     return
02516 
02517 def usage(exit_status):
02518     from sys import exit
02519     from sys import argv
02520     print "Usage: %s --module"%(argv[0])
02521     exit(exit_status)
02522     return
02523 
02524 if __name__ == "__main__":
02525     #
02526     from sys import argv
02527     if len(argv) != 2:
02528         usage(1)
02529         pass
02530     #
02531     module = argv[1]
02532     if module.find('--') != 0:
02533         usage(1)
02534         pass
02535     module = module[2:]
02536     if len(module) == 0:
02537         usage(1)
02538         pass
02539     #
02540     from os import getcwd
02541     the_root = getcwd()
02542     #
02543     nok = 0
02544     #
02545     from os import getenv
02546     from os import walk
02547     for root, dirs, files in walk(the_root):
02548         # --
02549         # E.A. : Remove 'CVS' in dirs
02550         # E.A. : It allows to not recurse in CVS dirs
02551         # E.A. : See os module python documentation
02552         # --
02553         try:
02554             dirs.remove('CVS')
02555         except ValueError:
02556             pass
02557         # --
02558         if "Makefile.am.cmake" in files:
02559             if "Makefile.am" in files:
02560                 files.remove("Makefile.am")
02561                 pass
02562             pass
02563         # --
02564         for f in files:
02565             if f in ["Makefile.am", "Makefile.am.cmake"]:
02566                 convert = True
02567                 if getenv("AM2CMAKE_FORCE_GENERATION", "0")=="0":
02568                     # detect if conversion should be done
02569                     if "CMakeLists.txt" in files:
02570                         from os.path import join
02571                         ff = open(join(root, "CMakeLists.txt"))
02572                         content = ff.read()
02573                         ff.close()
02574                         if content.find("generated by am2cmake") == -1:
02575                             convert = False
02576                             pass
02577                         pass                       
02578                     pass
02579                 if convert:
02580                     convertAmFile(the_root, root, dirs, files, f, module)
02581                     nok += 1
02582                 pass
02583             pass
02584         pass
02585     #
02586     from sys import stdout
02587     if nok:
02588         if nok == 1:
02589             msg = "%s file has been converted to cmake"%(nok)
02590         else:
02591             msg = "%s files have been converted to cmake"%(nok)
02592             pass
02593         stdout.write(msg)
02594         stdout.write("\n")
02595         stdout.flush()
02596         pass
02597     pass