1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # A set of regular expressions used ...
28 p_multiline = re.compile(r"""
34 p_dollar = re.compile(r"""
36 (?P<val> # open the group val
37 [^)]* # the group contain 0 or more non ) characters
42 p_arobas = re.compile(r"""
44 (?P<val> # open the group val
45 [^@]* # the group contain 0 or more non @ characters
50 p_if = re.compile(r"""
51 ^ # beginning of the string
55 (?P<val> # open the group val
56 [^\s]+ # the group contain 1 or more non space characters
60 p_else = re.compile(r"""
61 ^ # beginning of the line
67 p_endif = re.compile(r"""
68 ^ # beginning of the line
74 p_attribution = re.compile(r"""
75 ^ # beginning of the line
76 (?P<spaces> # open the group spaces
79 (?P<key> # open the group key
80 \w+ # the group contain 1 or more alphanumeric characters
83 (?P<method> # open the group method
87 (?P<value> # open the group value
88 .* # 0 or more any characters
94 class CMakeFile(object):
96 def __init__(self, the_root, root, dirs, files, f, module):
98 self.the_root = the_root
104 from os.path import join
105 self.amFile = join(root, f)
106 self.listsFile = join(root, "CMakeLists.txt")
115 # Read the Makefile.am file
118 stream = open(amFile)
119 content = stream.read()
123 # Replace the composed lines separated by "\\n" by an unique line
125 content = p_multiline.sub(r' ', content)
128 # Compatibility netgen plugin
130 content = content.replace("../NETGEN/libNETGEN.la", "${NETGEN_LIBS}")
205 "vtkGraphicsPythonD",
217 "SalomeCommunication",
219 "SalomeDSCContainer",
227 "SalomeLifeCycleCORBA",
229 "SalomeLoggerServer",
230 "SalomeNotification",
232 "SalomeResourcesManager",
234 "with_loggerTraceCollector",
286 "GEOMFiltersSelection",
310 "InterpGeometric2DAlg",
339 "SMESHFiltersSelection",
347 full_list = cas_list + vtk_list
348 full_list += kernel_list + gui_list
349 full_list += geom_list + med_list + smesh_list
351 # E.A. : sort by len before substitution ...
352 # Why ? Thing to "-lMEDWrapper" then "-lMEDWrapper_V2_1" substition
353 # And you understand ...
355 full_list.sort(cmp = lambda x, y : cmp(len(y), len(x)))
357 for key in full_list:
358 content = content.replace("-l%s"%(key), "${%s}"%(key))
362 # Split content in lines to treat each one separately
364 lines = content.split('\n')
367 # newlines contains the lines of the future CMakeLists.txt file
372 # opened_ifs is used to deals with nested conditionnals
377 # the __thedict__ dictionnary contains key, val
378 # of the Makefile.am file
380 self.__thedict__ = {}
383 # Initialize file ... mainly includes other cmake files
385 self.initialize(newlines)
388 # Do the job for each line
391 self.treatLine(line, newlines, opened_ifs)
395 # Finalize file ... it is in here the cmake job is done
397 self.finalize(newlines)
400 # Concatenate newlines into content
402 content = '\n'.join(newlines)
405 # Add a CR at end if necessary
407 lines = content.split('\n')
408 # lines = [ l.strip() for l in lines ]
409 if len(lines[-1]) != 0:
412 content = '\n'.join(lines)
415 self.content = content
420 def initialize(self, newlines):
421 if self.root == self.the_root:
424 CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
425 IF(COMMAND cmake_policy)
426 cmake_policy(SET CMP0003 NEW)
427 ENDIF(COMMAND cmake_policy)
430 if self.module == "kernel":
432 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
433 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
434 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
435 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
436 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
437 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
438 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
439 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
440 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
445 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
446 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
447 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
448 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
449 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
450 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
451 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
452 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
453 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
454 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
455 INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
457 if self.module == "gui":
459 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindCAS.cmake)
460 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQT4.cmake)
461 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
462 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindVTK.cmake)
463 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQWT.cmake)
464 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
468 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR})
469 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindCAS.cmake)
470 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQT4.cmake)
471 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
472 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindVTK.cmake)
473 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQWT.cmake)
474 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
475 INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindGUI.cmake)
477 if self.module == "med":
479 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
482 if self.module == "smesh":
484 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
485 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
486 INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
487 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake)
488 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
491 if self.module == "netgenplugin":
493 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
494 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
495 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
496 INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
497 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
498 INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
499 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindNETGEN.cmake)
502 if self.module == "blsurfplugin":
504 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
505 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
506 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
507 INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
508 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
509 INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
510 INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindBLSURF.cmake)
513 if self.module == "hexoticplugin":
515 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
516 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
517 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
518 INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
519 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
520 INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
523 if self.module == "ghs3dplugin":
525 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR})
526 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
527 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR})
528 INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
529 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
530 INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake)
533 if self.module == "visu":
535 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR})
536 INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake)
542 if self.module == "kernel":
547 set(XVERSION 0x050102)
548 SET(CALCIUM_IDL_INT_F77 long)
549 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
552 elif self.module == "gui":
554 SET(GUI_ENABLE_CORBA ${CORBA_GEN})
555 SET(ENABLE_VTKVIEWER ON)
556 SET(ENABLE_SALOMEOBJECT ON)
557 SET(ENABLE_OCCVIEWER ON)
558 SET(ENABLE_GLVIEWER ON)
559 SET(ENABLE_PLOT2DVIEWER ON)
560 SET(ENABLE_PYCONSOLE ON)
561 SET(ENABLE_SUPERVGRAPHVIEWER ON)
562 # SET(ENABLE_QXGRAPHVIEWER ON)
564 set(XVERSION 0x050102)
567 elif self.module == "geom":
569 SET(GEOM_ENABLE_GUI ON)
572 elif self.module == "medfile":
574 SET(MED_NUM_MAJEUR 2)
575 SET(MED_NUM_MINEUR 3)
576 SET(MED_NUM_RELEASE 5)
579 SET(FLIBS -lgfortranbegin -lgfortran)
583 elif self.module == "med":
585 SET(MED_ENABLE_KERNEL ON)
586 SET(MED_ENABLE_GUI ON)
589 elif self.module == "smesh":
591 SET(SMESH_ENABLE_GUI ON)
594 elif self.module == "netgenplugin":
596 SET(NETGENPLUGIN_ENABLE_GUI ON)
599 elif self.module == "blsurfplugin":
601 SET(BLSURFPLUGIN_ENABLE_GUI ON)
608 SET(VERSION_INFO 0.0.0)
609 SET(SOVERSION_INFO 0)
618 def treatLine(self, line, newlines, opened_ifs):
621 # Print the comment above the line itself
623 if line.find('#') >= 0:
624 fields = line.split('#')
626 comment = '#'.join([''] + fields[1:])
627 newlines.append(comment)
633 # If the line begins with 'include ', just comment it
635 if line.find("include ") == 0:
636 newlines.append("# " + line)
640 # If the line begins with '-include', just comment it
642 if line.find("-include") == 0:
643 newlines.append("# " + line)
647 # If the line is a definition of a make rule, just comment it
649 if line.count(':') == 1:
650 newlines.append("# " + line)
654 # A particuliar case where there are two ":" on the same line
656 if line.find('install-exec-local:') == 0:
657 newlines.append("# " + line)
661 # If the line begin by a tabulation, consider it's a makefile command and comment it
663 if line.find("\t") == 0:
664 newlines.append("# " + line)
669 key = "-version-info"
670 if line.find(key) >= 0:
672 before = line.split(key)[0]
673 after = line[len(before)+len(key):]
676 version_info = after.split()[0]
677 line = line.replace(key+sep+version_info, "")
679 version_info = version_info.replace(':', '.')
680 soversion_info = version_info.split('.')[0]
681 newlines.append("SET(VERSION_INFO " + version_info + ")")
682 newlines.append("SET(SOVERSION_INFO " + soversion_info + ")")
687 # Replace the $(TOTO) by ${TOTO}
688 # Replace the @TOTO@ by ${TOTO}
690 line = p_dollar.sub(r"${\1}", line)
691 line = p_arobas.sub(r"${\1}", line)
694 line = line.replace(r"${top_builddir}", r"${CMAKE_BINARY_DIR}")
695 line = line.replace(r"${top_srcdir}", r"${CMAKE_SOURCE_DIR}")
696 line = line.replace(r"${srcdir}", r"${CMAKE_CURRENT_SOURCE_DIR}")
697 line = line.replace(r"${builddir}", r"${CMAKE_CURRENT_BINARY_DIR}")
698 line = line.replace(r"${datadir}", r"${CMAKE_INSTALL_PREFIX}/share")
701 # Check if the line is a 'if' condition
702 # If yes, replace it by a cmake grammar
704 match = p_if.match(line)
706 theif = match.group("val")
708 theif = "NOT " + theif[1:]
710 line = p_if.sub(r"IF(%s)"%(theif), line)
711 opened_ifs.append(theif)
712 newlines.append(line)
716 # Check if the line is a 'else' condition
717 # If yes, replace it by a cmake grammar
719 match = p_else.match(line)
721 line = "ELSE(%s)"%(opened_ifs[-1])
722 newlines.append(line)
726 # Check if the line is a 'endif' condition
727 # If yes, replace it by a cmake grammar
729 match = p_endif.match(line)
731 line = "ENDIF(%s)"%(opened_ifs[-1])
733 newlines.append(line)
737 # Check if the line is an attribution '=' or '+='
739 match = p_attribution.match(line)
741 self.treatAttribution(match, newlines)
745 newlines.append(line)
750 def treatAttribution(self, match, newlines):
752 spaces = match.group("spaces")
753 key = match.group("key")
754 method = match.group("method")
755 value = match.group("value")
756 # print [spaces, key, method, value]
759 # Open cmake SET command
761 newlines.append(spaces + "SET(" + key)
764 # If method is '+=', put the previous definition as first value
767 newlines.append("%s ${%s}"%(spaces, key))
771 fields = value.split()
772 for i in range(len(fields)):
773 newlines.append("%s %s"%(spaces, fields[i]))
779 # The try: except KeyError is here if the +=
780 # is an error which occurs in salome ...
783 self.__thedict__[key] += fields[:]
785 self.__thedict__[key] = fields[:]
789 self.__thedict__[key] = fields[:]
793 # Close cmake SET command
796 newlines.append("%s)"%(spaces))
800 def finalize(self, newlines):
803 # Convert the .in files in build dir
807 if f == "sstream.in":
809 if f in ["runContainer.in", "stopContainer.in"]:
810 if self.module == "med":
811 if self.root[-3:] == "csh":
815 if f == "SALOMEconfig.ref.in":
816 out = "SALOMEconfig.h"
821 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/%s)
824 SET(output ${CMAKE_CURRENT_BINARY_DIR}/%s)
827 MESSAGE(STATUS "Creation of ${output}")
828 CONFIGURE_FILE(${input} ${output})
834 # convert the SUBDIRS in cmake grammar
836 if 1: # self.__thedict__.has_key("SUBDIRS"):
838 FOREACH(dir ${SUBDIRS})
839 IF(NOT dir STREQUAL .)
840 ADD_SUBDIRECTORY(${dir})
841 ENDIF(NOT dir STREQUAL .)
842 ENDFOREACH(dir ${SUBDIRS})
848 for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES"]:
849 if self.__thedict__.has_key(key):
850 self.addLibTarget(key, newlines)
856 for key in ["bin_PROGRAMS"]:
857 if self.__thedict__.has_key(key):
858 self.addBinTarget(key, newlines)
864 if self.__thedict__.has_key("BASEIDL_FILES"):
865 if not self.__thedict__.has_key("IDL_FILES"):
866 self.__thedict__["IDL_FILES"] = self.__thedict__["BASEIDL_FILES"]
868 SET(IDL_FILES ${BASEIDL_FILES})
877 if self.__thedict__.has_key(key):
878 if self.module == "kernel":
880 SET(IDL_FILES ${IDL_FILES} Calcium_Ports.idl)
884 FOREACH(input ${IDL_FILES})
885 STRING(REGEX REPLACE ".idl" "" base ${input})
886 SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc)
888 SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc)
889 SET(outputs ${outputs} ${dynsrc})
890 IF(input STREQUAL Calcium_Ports.idl)
891 SET(input ${CMAKE_CURRENT_BINARY_DIR}/${input})
892 ELSE(input STREQUAL Calcium_Ports.idl)
893 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
894 ENDIF(input STREQUAL Calcium_Ports.idl)
897 COMMAND ${OMNIORB_IDL} ${IDLCXXFLAGS} ${OMNIORB_IDLCXXFLAGS} ${input}
898 MAIN_DEPENDENCY ${input}
900 install(FILES ${input} DESTINATION idl/salome)
901 SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
902 install(FILES ${IDL_HEADER} DESTINATION include/salome)
903 INSTALL(CODE "SET(IDL_FILE ${input})")
904 INSTALL(CODE "SET(DIR lib/python${PYTHON_VERSION}/site-packages/salome)")
905 INSTALL(CODE "SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})")
906 INSTALL(CODE "SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL_PYTHON})")
909 FOREACH(f ${IDLPYFLAGS})
910 SET(flags "${flags} ${f}")
911 ENDFOREACH(f ${IDLPYFLAGS})
912 SET(IDLPYFLAGS ${flags})
913 STRING(REPLACE "\\\\" "/" IDLPYFLAGS ${IDLPYFLAGS})
914 INSTALL(CODE "SET(IDLPYFLAGS ${IDLPYFLAGS})")
917 if self.module == "kernel":
919 INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
923 STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
924 INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake)
928 ENDFOREACH(input ${IDL_FILES})
934 for key in ["SWIG_SRC", "SWIGSOURCES", "SWIG_DEF"]:
935 if self.__thedict__.has_key(key):
937 SET(SWIG_SOURCES ${%s})
939 self.__thedict__["SWIG_SOURCES"] = self.__thedict__[key]
945 if self.__thedict__.has_key("SWIG_SOURCES"):
947 IF(SWIG_SOURCES MATCHES ";")
948 STRING(REGEX REPLACE ";.*" "" SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
949 ELSE(SWIG_SOURCES MATCHES ";")
950 SET(SWIG_SOURCES_FIRST "${SWIG_SOURCES}")
951 ENDIF(SWIG_SOURCES MATCHES ";")
954 COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${MY_SWIG_FLAGS} -o ${build_srcs} ${CMAKE_CURRENT_SOURCE_DIR}/${SWIG_SOURCES_FIRST}
955 MAIN_DEPENDENCY ${SWIG_SOURCES}
963 if self.__thedict__.has_key(key):
965 FOREACH(output ${MOC_FILES})
966 STRING(REGEX REPLACE _moc.cxx .h input ${output})
967 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
968 SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
971 COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input} -o ${output}
972 MAIN_DEPENDENCY ${input}
974 ENDFOREACH(output ${MOC_FILES})
981 if self.__thedict__.has_key(key):
983 FOREACH(output ${UIC_FILES})
984 STRING(REPLACE "ui_" "" input ${output})
985 STRING(REPLACE ".h" ".ui" input ${input})
986 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
987 SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
990 COMMAND ${QT_UIC_EXECUTABLE} -o ${output} ${input}
991 MAIN_DEPENDENCY ${input}
993 ENDFOREACH(output ${UIC_FILES})
1000 if self.__thedict__.has_key(key):
1002 FOREACH(output ${QRC_FILES})
1003 STRING(REGEX REPLACE "qrc_" "" input ${output})
1004 STRING(REGEX REPLACE ".cxx" ".qrc" input ${input})
1005 STRING(REGEX REPLACE ".qrc" "" name ${input})
1006 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
1007 SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
1010 COMMAND ${QT_RCC_EXECUTABLE} ${input} -o ${output} -name ${name}
1011 MAIN_DEPENDENCY ${input}
1013 ENDFOREACH(output ${QRC_FILES})
1020 if self.__thedict__.has_key(key):
1022 FOREACH(input ${SIP_FILES})
1023 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
1025 FOREACH(out ${SIP_SRC})
1026 SET(output ${output} ${CMAKE_CURRENT_BINARY_DIR}/${out})
1027 ENDFOREACH(out ${SIP_SRC})
1030 COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${input}
1031 MAIN_DEPENDENCY ${input}
1033 ENDFOREACH(input ${SIP_FILES})
1038 # Treat the install targets
1041 "salomeadmux_DATA" : "salome_adm/unix",
1042 "dist_salomeadmux_DATA" : "salome_adm/unix",
1043 "dist_salome_cmake_DATA" : "salome_adm/cmake_files",
1044 "dist_salomem4_DATA" : "salome_adm/unix/config_files",
1045 "dist_salome4depr_DATA" : "salome_adm/unix/config_files/DEPRECATED",
1046 "dist_admlocalm4_DATA" : "adm_local/unix/config_files",
1047 "dist_admlocal_cmake_DATA" : "adm_local/cmake_files",
1048 "salomeinclude_DATA" : "include/salome",
1049 "salomeinclude_HEADERS" : "include/salome",
1050 "dist_salomeres_DATA" : "share/salome/resources/%s"%(self.module),
1051 "nodist_salomeres_DATA" : "share/salome/resources/%s"%(self.module),
1052 "nodist_salomeres_SCRIPTS" : "share/salome/resources/%s"%(self.module),
1053 "dist_salomescript_SCRIPTS" : "bin/salome",
1054 "dist_salomescript_DATA" : "bin/salome",
1055 "dist_salomescript_PYTHON" : "bin/salome",
1056 "nodist_salomescript_DATA" : "bin/salome",
1057 "salomepython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome",
1058 "nodist_salomepython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome",
1059 "sharedpkgpython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome/shared_modules",
1061 if self.module == "medfile":
1063 "include_HEADERS" : "include",
1064 "nodist_include_HEADERS" : "include",
1065 "bin_SCRIPTS" : "bin",
1066 "doc_DATA" : "${docdir}",
1069 for key, value in d.items():
1070 if self.__thedict__.has_key(key):
1071 self.addInstallTarget(key, value, newlines)
1078 def setLibAdd(self, key, newlines):
1080 newlines.append(r'''
1084 newlines.append(r'''
1087 SET(targets ${targets} MEFISTO2D)
1088 FOREACH(target ${targets})
1089 IF(name STREQUAL ${target})
1090 SET(dir $ENV{F2CHOME})
1091 STRING(REPLACE "\\\\" "/" dir ${dir})
1092 SET(libadd ${libadd} ${dir}/LIBF77.lib)
1093 SET(libadd ${libadd} ${dir}/LIBI77.lib)
1094 ENDIF(name STREQUAL ${target})
1095 ENDFOREACH(target ${targets})
1099 newlines.append(r'''
1100 SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS})
1101 FOREACH(lib SALOMEBasics SalomeBatch)
1102 IF(name STREQUAL lib)
1103 SET(libs ${libs} ${PTHREAD_LIBS})
1104 ENDIF(name STREQUAL lib)
1105 ENDFOREACH(lib SALOMEBasics SalomeBatch)
1107 if key == "bin_PROGRAMS":
1108 newlines.append(r'''
1109 SET(libs ${libs} ${LDADD})
1113 newlines.append(r'''
1114 FOREACH(lib ${libs})
1115 GET_FILENAME_COMPONENT(ext ${lib} EXT)
1116 IF(ext STREQUAL .la)
1117 GET_FILENAME_COMPONENT(lib ${lib} NAME_WE)
1118 STRING(REPLACE "lib" "" lib ${lib})
1119 ENDIF(ext STREQUAL .la)
1121 SET(vars ${vars} -no-undefined)
1123 SET(vars ${vars} -module)
1124 SET(vars ${vars} -Wl,-E)
1125 SET(vars ${vars} -Xlinker)
1126 SET(vars ${vars} -export-dynamic)
1127 SET(vars ${vars} -lm)
1128 SET(vars ${vars} -lboost_thread)
1129 SET(vars ${vars} -lboost_signals)
1130 SET(vars ${vars} -lvtkWidgets)
1135 ENDIF(lib STREQUAL v)
1136 ENDFOREACH(v ${vars})
1137 SET(libadd ${libadd} ${lib})
1138 ENDFOREACH(lib ${libs})
1139 TARGET_LINK_LIBRARIES(${name} ${libadd})
1142 newlines.append(r'''
1145 SET(targets ${targets} MEFISTO2D)
1146 FOREACH(target ${targets})
1147 IF(name STREQUAL ${target})
1148 IF(CMAKE_BUILD_TYPE STREQUAL Debug)
1149 SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
1150 ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
1151 ENDIF(name STREQUAL ${target})
1152 ENDFOREACH(target ${targets})
1158 def setCompilationFlags(self, key, newlines):
1159 newlines.append(r'''
1163 SET(targets ${targets} SalomeIDLKernel)
1164 SET(targets ${targets} SalomeDS)
1165 SET(targets ${targets} SALOMEDSTest)
1166 SET(targets ${targets} SALOMEDS_Client_exe)
1167 SET(targets ${targets} SalomeIDLGEOM)
1168 SET(targets ${targets} GEOMEngine)
1169 SET(targets ${targets} MEDEngine)
1170 SET(targets ${targets} SMESHEngine)
1171 SET(targets ${targets} SMESH)
1172 FOREACH(target ${targets})
1173 IF(name STREQUAL ${target})
1174 SET(var ${var} -DNOGDI)
1175 ENDIF(name STREQUAL ${target})
1176 ENDFOREACH(target ${targets})
1180 newlines.append(r'''
1183 SET(targets ${targets} MEFISTO2D)
1184 FOREACH(target ${targets})
1185 IF(name STREQUAL ${target})
1186 SET(dir $ENV{F2CHOME})
1187 STRING(REPLACE "\\\\" "/" dir ${dir})
1188 SET(var ${var} -I${dir})
1189 ENDIF(name STREQUAL ${target})
1190 ENDFOREACH(target ${targets})
1194 if self.module in ["geom", "med"]:
1195 newlines.append(r'''
1196 SET(var ${var} -I${CMAKE_CURRENT_SOURCE_DIR})
1197 SET(var ${var} -I${CMAKE_CURRENT_BINARY_DIR})
1200 if key == "bin_PROGRAMS":
1201 newlines.append(r'''
1202 SET(var ${var} ${AM_CPPFLAGS})
1203 SET(var ${var} ${AM_CXXFLAGS})
1206 newlines.append(r'''
1207 SET(var ${var} ${PLATFORM_CPPFLAGS})
1208 SET(var ${var} ${PTHREAD_CFLAGS})
1209 SET(var ${var} ${${amname}_CPPFLAGS})
1210 SET(var ${var} ${${amname}_CXXFLAGS})
1211 SET(var ${var} ${${amname}_CFLAGS})
1214 SET(vars ${vars} -include SALOMEconfig.h)
1215 SET(vars ${vars} -ftemplate-depth-32)
1223 ENDFOREACH(v ${vars})
1224 SET(flags "${flags} ${f}")
1225 ENDFOREACH(f ${var})
1226 SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}")
1230 def addLibTarget(self, key, newlines):
1231 newlines.append(r'''
1232 FOREACH(amname ${%s})
1235 # Replace .la by _la ...
1237 newlines.append(r'''
1238 STRING(REPLACE .la _la amname ${amname})
1241 # Remove the _la for the cmake name
1243 newlines.append(r'''
1244 STRING(LENGTH ${amname} len)
1245 MATH(EXPR newlen "${len}-3")
1246 STRING(SUBSTRING ${amname} 0 ${newlen} name)
1249 # Does the target begins with lib ??
1250 # If yes, remove lib at beginning for cmake name
1252 newlines.append(r'''
1253 STRING(REGEX MATCH "^lib" BEGIN_WITH_lib ${name})
1255 STRING(LENGTH ${name} len)
1256 MATH(EXPR newlen "${len}-3")
1257 STRING(SUBSTRING ${name} 3 ${newlen} name)
1258 ENDIF(BEGIN_WITH_lib)
1261 # Does the target is an idl library
1263 newlines.append(r'''
1264 STRING(REGEX MATCH "IDL" ISIDL ${name})
1267 # Set the type of the library
1269 newlines.append(r'''
1281 # Set sources for the library
1283 newlines.append(r'''
1285 FOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
1286 GET_FILENAME_COMPONENT(ext ${src} EXT)
1288 IF(src STREQUAL trte.f)
1289 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
1290 STRING(REPLACE ".f" ".c" src ${src})
1291 SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
1295 COMMAND f2c ${input}
1296 MAIN_DEPENDENCY ${input}
1298 ELSE(src STREQUAL trte.f)
1299 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${src})
1300 STRING(REPLACE ".f" ".o" src ${src})
1301 SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src})
1310 COMMAND ${F77} -c -o ${output} ${input}
1311 MAIN_DEPENDENCY ${input}
1313 ENDIF(src STREQUAL trte.f)
1314 ENDIF(ext STREQUAL .f)
1315 SET(srcs ${srcs} ${src})
1316 ENDFOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
1318 newlines.append(r'''
1321 newlines.append(r'''
1322 SET(l ${nodist_${amname}_SOURCES} ${BUILT_SOURCES})
1324 newlines.append(r'''
1326 GET_FILENAME_COMPONENT(ext ${f} EXT)
1327 IF(ext STREQUAL .py)
1328 ELSE(ext STREQUAL .py)
1329 SET(build_srcs ${build_srcs} ${CMAKE_CURRENT_BINARY_DIR}/${f})
1330 ENDIF(ext STREQUAL .py)
1332 SET(srcs ${build_srcs} ${srcs})
1335 # Add the library to cmake
1337 newlines.append(r'''
1338 ADD_LIBRARY(${name} ${type} ${srcs})
1341 # The compilation flags
1343 self.setCompilationFlags(key, newlines)
1345 newlines.append(r'''
1346 SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${VERSION_INFO} SOVERSION ${SOVERSION_INFO})
1349 self.setLibAdd(key, newlines)
1351 if 1: # key != "noinst_LTLIBRARIES":
1352 if self.module == "medfile":
1353 newlines.append(r'''
1357 newlines.append(r'''
1358 SET(DEST lib/salome)
1361 newlines.append(r'''
1363 INSTALL(TARGETS ${name} DESTINATION ${DEST})
1365 if self.module == "gui":
1366 newlines.append(r'''
1367 FOREACH(lib SalomePyQt)
1368 IF(name STREQUAL lib)
1370 IF(CMAKE_BUILD_TYPE STREQUAL Release)
1371 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}.pyd)
1372 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
1373 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME ${name}_d.pyd)
1374 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
1376 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION ${DEST} RENAME ${name}.so)
1378 ENDIF(name STREQUAL lib)
1379 ENDFOREACH(lib SalomePyQt)
1380 FOREACH(lib SalomePy)
1381 IF(name STREQUAL lib)
1383 IF(CMAKE_BUILD_TYPE STREQUAL Release)
1384 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.pyd)
1385 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
1386 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}_d.pyd)
1387 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
1389 ENDIF(name STREQUAL lib)
1390 ENDFOREACH(lib SalomePy)
1393 if self.module == "geom":
1394 newlines.append(r'''
1396 STRING(REGEX MATCH "Export" ISExport ${name})
1398 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
1400 STRING(REGEX MATCH "Import" ISImport ${name})
1402 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.dll DESTINATION ${DEST} RENAME lib${name}.dll)
1407 newlines.append(r'''
1408 ELSE(BEGIN_WITH_lib)
1410 newlines.append(r'''
1412 INSTALL(TARGETS ${name} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome)
1413 IF(CMAKE_BUILD_TYPE STREQUAL Release)
1414 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome/${name}.dll DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.pyd)
1415 ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
1416 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome/${name}.dll DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}_d.pyd)
1417 ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
1419 GET_TARGET_PROPERTY(version ${name} VERSION)
1420 GET_TARGET_PROPERTY(soversion ${name} SOVERSION)
1421 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so.${version})
1422 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so.${soversion})
1423 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so)
1426 newlines.append(r'''
1427 ENDIF(BEGIN_WITH_lib)
1431 newlines.append(r'''
1432 ENDFOREACH(amname ${%s})
1437 def addBinTarget(self, key, newlines):
1439 newlines.append(r'''
1440 FOREACH(amname ${bin_PROGRAMS})
1443 newlines.append(r'''
1444 SET(name "${amname}_exe")
1445 SET(srcs ${${amname}_SOURCES} ${dist_${amname}_SOURCES})
1446 LIST(LENGTH srcs nb)
1448 ADD_EXECUTABLE(${name} ${srcs})
1451 self.setCompilationFlags(key, newlines)
1453 self.setLibAdd(key, newlines)
1455 if self.module == "medfile":
1456 newlines.append(r'''
1460 newlines.append(r'''
1461 SET(DEST bin/salome)
1465 newlines.append(r'''
1467 INSTALL(TARGETS ${name} DESTINATION ${DEST})
1468 INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe DESTINATION ${DEST} RENAME ${amname}.exe)
1469 INSTALL(CODE "FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${name}.exe)")
1472 SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
1473 SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
1474 SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
1475 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name} DESTINATION ${DEST} PERMISSIONS ${PERMS} RENAME ${amname})
1479 newlines.append(r'''
1483 newlines.append(r'''
1484 ENDFOREACH(amname ${bin_PROGRAMS})
1489 def addInstallTarget(self, key, destination, newlines):
1490 newlines.append(r"FOREACH(f ${%s})"%(key))
1491 newlines.append(r'''
1494 newlines.append(r'''
1495 STRING(COMPARE EQUAL ${f} SALOMEconfig.h.in test_SALOMEconfig.h.in)
1496 IF(test_SALOMEconfig.h.in)
1497 INSTALL(FILES SALOMEconfig.ref.in DESTINATION ${DEST} RENAME SALOMEconfig.h.in)
1498 ELSE(test_SALOMEconfig.h.in)
1499 SET(dummy dummy-NOTFOUND)
1500 MARK_AS_ADVANCED(dummy)
1501 # FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${f})
1502 FIND_FILE(dummy ${f} PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
1505 if key in ['dist_salomescript_SCRIPTS']:
1506 newlines.append(r'''
1508 SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
1509 SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
1510 SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
1511 INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
1514 newlines.append(r'''
1515 GET_FILENAME_COMPONENT(ext ${f} EXT)
1516 IF(ext STREQUAL .py)
1517 IF(DEST STREQUAL bin/salome)
1519 SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE)
1520 SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE)
1521 SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE)
1522 INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS})
1523 ELSE(DEST STREQUAL bin/salome)
1524 INSTALL(FILES ${f} DESTINATION ${DEST})
1525 ENDIF(DEST STREQUAL bin/salome)
1526 ELSE(ext STREQUAL .py)
1527 INSTALL(FILES ${f} DESTINATION ${DEST})
1528 ENDIF(ext STREQUAL .py)
1531 newlines.append(r'''
1533 GET_FILENAME_COMPONENT(ext ${f} EXT)
1534 IF(ext STREQUAL .qm)
1535 STRING(REGEX REPLACE .qm .ts input ${f})
1537 if self.module in ["kernel", "gui"]:
1538 newlines.append(r'''
1539 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/resources/${input})
1542 newlines.append(r'''
1543 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
1546 newlines.append(r'''
1547 SET(output ${CMAKE_CURRENT_BINARY_DIR}/${f})
1548 # ADD_CUSTOM_COMMAND(
1550 # COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output}
1551 # MAIN_DEPENDENCY ${input}
1553 EXECUTE_PROCESS(COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output})
1554 ENDIF(ext STREQUAL .qm)
1555 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${DEST})
1557 ENDIF(test_SALOMEconfig.h.in)
1559 newlines.append(r'''
1560 GET_FILENAME_COMPONENT(ext ${f} EXT)
1561 IF(ext STREQUAL .py)
1562 INSTALL(CODE "SET(PYTHON_FILE ${f})")
1563 INSTALL(CODE "SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})")
1564 INSTALL(CODE "SET(DEST ${DEST})")
1565 INSTALL(CODE "SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})")
1567 if self.module == "kernel":
1569 IF(f STREQUAL SALOME_ContainerPy.py)
1570 ELSE(f STREQUAL SALOME_ContainerPy.py)
1571 IF(f STREQUAL am2cmake.py)
1572 ELSE(f STREQUAL am2cmake.py)
1573 INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
1574 ENDIF(f STREQUAL am2cmake.py)
1575 ENDIF(f STREQUAL SALOME_ContainerPy.py)
1579 STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR})
1580 INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
1583 newlines.append(r'''
1584 ENDIF(ext STREQUAL .py)
1586 newlines.append(r"ENDFOREACH(f ${%s})"%(key))
1589 def writeListsFile(self):
1590 f = open(self.listsFile, "w")
1591 f.write(self.content)
1597 def convertAmFile(the_root, root, dirs, files, f, module):
1598 cmake = CMakeFile(the_root, root, dirs, files, f, module)
1599 cmake.writeListsFile()
1602 def usage(exit_status):
1603 from sys import exit
1604 from sys import argv
1605 print "Usage: %s --module"%(argv[0])
1609 if __name__ == "__main__":
1611 from sys import argv
1617 if module.find('--') != 0:
1621 if len(module) == 0:
1625 from os import getcwd
1629 for root, dirs, files in walk(the_root):
1631 # E.A. : Remove 'CVS' in dirs
1632 # E.A. : It allows to not recurse in CVS dirs
1633 # E.A. : See os module python documentation
1641 if f == "Makefile.am":
1642 convertAmFile(the_root, root, dirs, files, f, module)