From bc372eb7d94ca9499c6d056e69c763a0e9ecc974 Mon Sep 17 00:00:00 2001 From: abd Date: Tue, 28 Oct 2008 14:18:59 +0000 Subject: [PATCH] BUG 0020023: A contribution to compile KERNEL with cmake This integration adds support of cross-platform cmake compilation for KERNEL module. WARNING. current version supports Python 2.5 only --- build_cmake | 9 + salome_adm/Makefile.am | 2 +- salome_adm/cmake_files/FindBOOST.cmake | 7 + salome_adm/cmake_files/FindCPPUNIT.cmake | 5 + salome_adm/cmake_files/FindHDF5.cmake | 29 + salome_adm/cmake_files/FindKERNEL.cmake | 40 + salome_adm/cmake_files/FindLIBXML2.cmake | 22 + salome_adm/cmake_files/FindOMNIORB.cmake | 92 ++ salome_adm/cmake_files/FindPLATFORM.cmake | 28 + salome_adm/cmake_files/FindPTHREADS.cmake | 9 + salome_adm/cmake_files/FindPYTHON.cmake | 31 + salome_adm/cmake_files/FindSWIG.cmake | 3 + salome_adm/cmake_files/Makefile.am | 33 + salome_adm/cmake_files/am2cmake.py | 950 ++++++++++++++++++ .../cmake_files/install_python_from_idl.cmake | 5 + 15 files changed, 1264 insertions(+), 1 deletion(-) create mode 100755 build_cmake create mode 100644 salome_adm/cmake_files/FindBOOST.cmake create mode 100644 salome_adm/cmake_files/FindCPPUNIT.cmake create mode 100644 salome_adm/cmake_files/FindHDF5.cmake create mode 100644 salome_adm/cmake_files/FindKERNEL.cmake create mode 100644 salome_adm/cmake_files/FindLIBXML2.cmake create mode 100644 salome_adm/cmake_files/FindOMNIORB.cmake create mode 100644 salome_adm/cmake_files/FindPLATFORM.cmake create mode 100644 salome_adm/cmake_files/FindPTHREADS.cmake create mode 100644 salome_adm/cmake_files/FindPYTHON.cmake create mode 100644 salome_adm/cmake_files/FindSWIG.cmake create mode 100644 salome_adm/cmake_files/Makefile.am create mode 100644 salome_adm/cmake_files/am2cmake.py create mode 100644 salome_adm/cmake_files/install_python_from_idl.cmake diff --git a/build_cmake b/build_cmake new file mode 100755 index 000000000..347fdee25 --- /dev/null +++ b/build_cmake @@ -0,0 +1,9 @@ +#!/bin/sh + +CURRENT_DIR=`pwd` +CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` +cd ${CONF_DIR} +python salome_adm/cmake_files/am2cmake.py --kernel +status=$? +cd ${CURRENT_DIR} +exit $status diff --git a/salome_adm/Makefile.am b/salome_adm/Makefile.am index 5fa052423..615598cab 100644 --- a/salome_adm/Makefile.am +++ b/salome_adm/Makefile.am @@ -16,5 +16,5 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SUBDIRS = unix +SUBDIRS = unix cmake_files AUTOMAKE_OPTIONS=filename-length-max=255 diff --git a/salome_adm/cmake_files/FindBOOST.cmake b/salome_adm/cmake_files/FindBOOST.cmake new file mode 100644 index 000000000..4cfdea963 --- /dev/null +++ b/salome_adm/cmake_files/FindBOOST.cmake @@ -0,0 +1,7 @@ + +SET(BOOST_ROOT $ENV{BOOST_ROOT}) +IF(BOOST_ROOT) + FIND_PATH(BOOST_INCLUDES boost/shared_ptr.hpp ${BOOST_ROOT}) + # FIND_LIBRARY(BOOST_LIBS boost_thread-vc80-mt-1_34_1 ${BOOST_ROOT}/lib) + SET(BOOST_CPPFLAGS -I${BOOST_INCLUDES}) +ENDIF(BOOST_ROOT) diff --git a/salome_adm/cmake_files/FindCPPUNIT.cmake b/salome_adm/cmake_files/FindCPPUNIT.cmake new file mode 100644 index 000000000..38a121ef9 --- /dev/null +++ b/salome_adm/cmake_files/FindCPPUNIT.cmake @@ -0,0 +1,5 @@ + +FIND_LIBRARY(CPPUNIT_LIBS cppunit /usr/lib) +IF(CPPUNIT_LIBS) + SET(CPPUNIT_IS_OK 1) +ENDIF(CPPUNIT_LIBS) diff --git a/salome_adm/cmake_files/FindHDF5.cmake b/salome_adm/cmake_files/FindHDF5.cmake new file mode 100644 index 000000000..7fdbc39d8 --- /dev/null +++ b/salome_adm/cmake_files/FindHDF5.cmake @@ -0,0 +1,29 @@ + +FIND_PROGRAM(HDF5_DUMP h5dump) + +SET(HDF5_ROOT ${HDF5_DUMP}) +GET_FILENAME_COMPONENT(HDF5_ROOT ${HDF5_ROOT} PATH) +GET_FILENAME_COMPONENT(HDF5_ROOT ${HDF5_ROOT} PATH) + +FIND_PATH(HDF5_INCLUDES H5public.h ${HDF5_ROOT}/include) +SET(HDF5_INCLUDES -I${HDF5_INCLUDES}) + +IF(WINDOWS) + FIND_LIBRARY(HDF5_LIBS hdf5d ${HDF5_ROOT}/lib) +ELSE(WINDOWS) + FIND_LIBRARY(HDF5_LIBS hdf5 ${HDF5_ROOT}/lib) +ENDIF(WINDOWS) + +#SET(ZLIB_ROOT $ENV{ZLIB_ROOT}) +#STRING(LENGTH "${ZLIB_ROOT}" NB) +#IF(${NB} GREATER 0) +# FIND_LIBRARY(ZLIB_LIBS zlib ${ZLIB_ROOT}/lib) +# SET(HDF5_LIBS ${HDF5_LIBS} ${ZLIB_LIBS}) +#ENDIF(${NB} GREATER 0) + +#SET(SZIP_ROOT $ENV{SZIP_ROOT}) +#STRING(LENGTH "${SZIP_ROOT}" NB) +#IF(${NB} GREATER 0) +# FIND_LIBRARY(SZIP_LIBS szlib ${SZIP_ROOT}/lib) +# SET(HDF5_LIBS ${HDF5_LIBS} ${SZIP_LIBS}) +#ENDIF(${NB} GREATER 0) diff --git a/salome_adm/cmake_files/FindKERNEL.cmake b/salome_adm/cmake_files/FindKERNEL.cmake new file mode 100644 index 000000000..27644a162 --- /dev/null +++ b/salome_adm/cmake_files/FindKERNEL.cmake @@ -0,0 +1,40 @@ + +SET(KERNEL_CXXFLAGS -I${KERNEL_ROOT_DIR}/include/salome) + +FIND_LIBRARY(SalomeIDLKernel SalomeIDLKernel ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeHDFPersist SalomeHDFPersist ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeNS SalomeNS ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMELocalTrace SALOMELocalTrace ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(OpUtil OpUtil ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeLifeCycleCORBA SalomeLifeCycleCORBA ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeCatalog SalomeCatalog ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeDSClient SalomeDSClient ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(with_loggerTraceCollector with_loggerTraceCollector ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeContainer SalomeContainer ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeResourcesManager SalomeResourcesManager ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(TOOLSDS TOOLSDS ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeDSImpl SalomeDSImpl ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeGenericObj SalomeGenericObj ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(Registry Registry ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeNotification SalomeNotification ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMEBasics SALOMEBasics ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeLauncher SalomeLauncher ${KERNEL_ROOT_DIR}/lib/salome) + + +#FIND_LIBRARY(__Batch_Swig __Batch_Swig ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(CalciumC CalciumC ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(DF DF ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(__NOTIFICATION __NOTIFICATION ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeBatch SalomeBatch ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(__SALOME_Comm __SALOME_Comm ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeCommunication SalomeCommunication ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeDatastream SalomeDatastream ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeDSCContainer SalomeDSCContainer ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeDSCSupervBasic SalomeDSCSupervBasic ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeDSCSuperv SalomeDSCSuperv ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeDS SalomeDS ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(__SALOME_LifeCycleCORBA __SALOME_LifeCycleCORBA ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeLoggerServer SalomeLoggerServer ${KERNEL_ROOT_DIR}/lib/salome) +#FIND_LIBRARY(SalomeTestComponentEngine SalomeTestComponentEngine ${KERNEL_ROOT_DIR}/lib/salome) + +#SET(KERNEL_ROOT_DIR_SLASH $ENV{KERNEL_ROOT_DIR_SLASH}) diff --git a/salome_adm/cmake_files/FindLIBXML2.cmake b/salome_adm/cmake_files/FindLIBXML2.cmake new file mode 100644 index 000000000..8b9a98ed3 --- /dev/null +++ b/salome_adm/cmake_files/FindLIBXML2.cmake @@ -0,0 +1,22 @@ + +SET(LIBXML2_ROOT $ENV{LIBXML2_ROOT}) +IF(LIBXML2_ROOT) + FIND_PATH(LIBXML2_INCLUDE_DIR libxml/parser.h ${LIBXML2_ROOT}/include) + FIND_LIBRARY(LIBXML2_LIBS libxml2 ${LIBXML2_ROOT}/lib) +ELSE(LIBXML2_ROOT) + FIND_PATH(LIBXML2_INCLUDE_DIR libxml/parser.h /usr/include/libxml2) + FIND_LIBRARY(LIBXML2_LIBS xml2 /usr/lib) +ENDIF(LIBXML2_ROOT) + +SET(LIBXML2_INCLUDES -I${LIBXML2_INCLUDE_DIR}) + +SET(ICONV_ROOT $ENV{ICONV_ROOT}) +IF(ICONV_ROOT) + FIND_PATH(ICONV_INCLUDE_DIR iconv.h ${ICONV_ROOT}/include) + FIND_LIBRARY(ICONV_LIBS iconv ${ICONV_ROOT}/lib) + SET(LIBXML2_INCLUDES ${LIBXML2_INCLUDES} -I${ICONV_INCLUDE_DIR}) + SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${ICONV_LIBS}) +ENDIF(ICONV_ROOT) + +SET(LIBXML_INCLUDES ${LIBXML2_INCLUDES}) +SET(LIBXML_LIBS ${LIBXML2_LIBS}) diff --git a/salome_adm/cmake_files/FindOMNIORB.cmake b/salome_adm/cmake_files/FindOMNIORB.cmake new file mode 100644 index 000000000..bed23c410 --- /dev/null +++ b/salome_adm/cmake_files/FindOMNIORB.cmake @@ -0,0 +1,92 @@ + +# ----- + +FIND_PROGRAM(OMNIORB_IDL omniidl) + +# ----- + +IF(OMNIORB_IDL) + SET(CORBA_GEN 1) +ELSE(OMNIORB_IDL) + SET(CORBA_GEN 0) +ENDIF(OMNIORB_IDL) + +# ----- + +SET(OMNIORB_ROOT ${OMNIORB_IDL}) +GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) +IF(WINDOWS) + GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) +ENDIF(WINDOWS) +GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) + +# ---- + +FIND_PATH(OMNIORB_INC1 + NAMES omniORB4/CORBA.h + PATHS ${OMNIORB_ROOT}/include + ) +FIND_PATH(OMNIORB_INC2 + NAMES CORBA.h + PATHS ${OMNIORB_ROOT}/include/omniORB4 + ) + +SET(OMNIORB_INCLUDES -I${OMNIORB_INC1} -I${OMNIORB_INC2}) +SET(CORBA_INCLUDES ${OMNIORB_INCLUDES}) + +# ---- + +SET(OMNIORB_CXXFLAGS) +SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -DOMNIORB_VERSION=4) +SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__x86__) + +IF(WINDOWS) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__WIN32__) + # # # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D_WIN32_WINNT=0x0400) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__NT__) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__OSVERSION__=4) +ELSE(WINDOWS) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__linux__) +ENDIF(WINDOWS) + +SET(CORBA_CXXFLAGS ${OMNIORB_CXXFLAGS}) + +# ---- + +IF(WINDOWS) + FIND_LIBRARY(lib_omniORB4 omniORB4_rtd ${OMNIORB_ROOT}/lib/x86_win32) + FIND_LIBRARY(lib_omniDynamic4 omniDynamic4_rtd ${OMNIORB_ROOT}/lib/x86_win32) + FIND_LIBRARY(lib_COS4 COS4_rtd ${OMNIORB_ROOT}/lib/x86_win32) + FIND_LIBRARY(lib_COSDynamic4 COSDynamic4_rtd ${OMNIORB_ROOT}/lib/x86_win32) + FIND_LIBRARY(lib_omnithread omnithread_rtd ${OMNIORB_ROOT}/lib/x86_win32) +ELSE(WINDOWS) + FIND_LIBRARY(lib_omniORB4 omniORB4 ${OMNIORB_ROOT}/lib) + FIND_LIBRARY(lib_omniDynamic4 omniDynamic4 ${OMNIORB_ROOT}/lib) + FIND_LIBRARY(lib_COS4 COS4 ${OMNIORB_ROOT}/lib) + FIND_LIBRARY(lib_COSDynamic4 COSDynamic4 ${OMNIORB_ROOT}/lib) + FIND_LIBRARY(lib_omnithread omnithread ${OMNIORB_ROOT}/lib) +ENDIF(WINDOWS) + +SET(OMNIORB_LIBS ${lib_omniORB4} ${lib_omniDynamic4} ${lib_COS4} ${lib_COSDynamic4} ${lib_omnithread}) +IF(WINDOWS) + SET(OMNIORB_LIBS ws2_32.lib mswsock.lib advapi32.lib ${OMNIORB_LIBS}) +ENDIF(WINDOWS) + +SET(CORBA_LIBS ${OMNIORB_LIBS}) + +# ---------------- + +SET(OMNIORB_IDL_PYTHON $ENV{OMNIIDL_PYTHON}) +IF(NOT OMNIORB_IDL_PYTHON) + SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL}) +ENDIF(NOT OMNIORB_IDL_PYTHON) + +# ---------------- + +SET(IDL_CLN_H .hh) +SET(IDL_SRV_H .hh) + +# SET(OMNIORB_IDLCXXFLAGS -Wba -nf) +# SET(OMNIORB_IDLPYFLAGS -bpython) +SET(IDLCXXFLAGS -Wba -nf) +SET(IDLPYFLAGS -bpython) diff --git a/salome_adm/cmake_files/FindPLATFORM.cmake b/salome_adm/cmake_files/FindPLATFORM.cmake new file mode 100644 index 000000000..b4d8d5360 --- /dev/null +++ b/salome_adm/cmake_files/FindPLATFORM.cmake @@ -0,0 +1,28 @@ + +MARK_AS_ADVANCED(ISSUE) +FIND_FILE(ISSUE issue /etc) +IF(ISSUE) + SET(WINDOWS 0) +ELSE() + SET(WINDOWS 1) +ENDIF(ISSUE) + +IF(WINDOWS) + SET(MACHINE WINDOWS) + SET(PLATFORM_CPPFLAGS) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} /W0) + # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT -D_CRT_SECURE_NO_WARNINGS) + # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_WIN32_WINNT=0x0500) + # SET(RM del) +ELSE(WINDOWS) + SET(MACHINE PCLINUX) + SET(PLATFORM_CPPFLAGS) + # SET(RM /bin/rm) +ENDIF(WINDOWS) + +## SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_) + +#SET(RCP rcp) +#SET(RSH rsh) +#SET(RCP rcp) diff --git a/salome_adm/cmake_files/FindPTHREADS.cmake b/salome_adm/cmake_files/FindPTHREADS.cmake new file mode 100644 index 000000000..77115f9b4 --- /dev/null +++ b/salome_adm/cmake_files/FindPTHREADS.cmake @@ -0,0 +1,9 @@ + +SET(PTHREADS_ROOT $ENV{PTHREADS_ROOT}) +IF(PTHREADS_ROOT) + FIND_PATH(PTHREADS_INCLUDE_DIR pthread.h ${PTHREADS_ROOT}/include) + IF(PTHREADS_INCLUDE_DIR) + SET(PTHREADS_INCLUDES -I${PTHREADS_INCLUDE_DIR}) + ENDIF(PTHREADS_INCLUDE_DIR) + FIND_LIBRARY(PTHREADS_LIBRARY pthreadVSE2d ${PTHREADS_ROOT}/lib) +ENDIF(PTHREADS_ROOT) diff --git a/salome_adm/cmake_files/FindPYTHON.cmake b/salome_adm/cmake_files/FindPYTHON.cmake new file mode 100644 index 000000000..b57878b7c --- /dev/null +++ b/salome_adm/cmake_files/FindPYTHON.cmake @@ -0,0 +1,31 @@ + +IF(WINDOWS) + FIND_PROGRAM(PYTHON_EXECUTABLE python_d) +ELSE(WINDOWS) + FIND_PROGRAM(PYTHON_EXECUTABLE python) +ENDIF(WINDOWS) + +SET(PYTHON_ROOT ${PYTHON_EXECUTABLE}) +GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) +GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) + +FIND_PATH(PYTHON_INCLUDE_PATH Python.h PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python2.5) + +IF(WINDOWS) + FIND_LIBRARY(PYTHON_LIBRARIES python25_d ${PYTHON_ROOT}/libs) +ELSE(WINDOWS) + FIND_LIBRARY(PYTHON_LIBRARIES python2.5 ${PYTHON_ROOT}/lib) +ENDIF(WINDOWS) + +SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH}) +SET(PYTHON_LIBS ${PYTHON_LIBRARIES}) + +IF(WINDOWS) + SET(PYTHON_VERSION python2.5) +ELSE(WINDOWS) + GET_FILENAME_COMPONENT(PYTHON_VERSION ${PYTHON_INCLUDE_PATH} NAME) +ENDIF(WINDOWS) + +IF(WINDOWS) + SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON) +ENDIF(WINDOWS) diff --git a/salome_adm/cmake_files/FindSWIG.cmake b/salome_adm/cmake_files/FindSWIG.cmake new file mode 100644 index 000000000..f78d1d4c5 --- /dev/null +++ b/salome_adm/cmake_files/FindSWIG.cmake @@ -0,0 +1,3 @@ + +FIND_PROGRAM(SWIG_EXECUTABLE swig) +SET(SWIG_FLAGS -c++ -python -shadow) diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am new file mode 100644 index 000000000..c18fa44f7 --- /dev/null +++ b/salome_adm/cmake_files/Makefile.am @@ -0,0 +1,33 @@ +# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG +# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +dist_salome_cmake_DATA = \ +am2cmake.py \ +FindBOOST.cmake \ +FindCPPUNIT.cmake \ +FindHDF5.cmake \ +FindKERNEL.cmake \ +FindLIBXML2.cmake \ +FindOMNIORB.cmake \ +FindPLATFORM.cmake \ +FindPTHREADS.cmake \ +FindPYTHON.cmake \ +FindSWIG.cmake \ +install_python_from_idl.cmake diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py new file mode 100644 index 000000000..5a3054f4e --- /dev/null +++ b/salome_adm/cmake_files/am2cmake.py @@ -0,0 +1,950 @@ + +import re + +# ---- +# A set of regular expressions used ... +# ---- + +p_multiline = re.compile(r""" +\\ # One backslash +\n # One CR +""", re.VERBOSE) + +p_dollar = re.compile(r""" +\$\( # a $ then a ( +(?P # open the group val +[^)]* # the group contain 0 or more non ) characters +) # close the group +\) # a ) at the end +""", re.VERBOSE) + +p_arobas = re.compile(r""" +@ # a @ +(?P # open the group val +[^@]* # the group contain 0 or more non @ characters +) # close the group +@ # a @ at the end +""", re.VERBOSE) + +p_if = re.compile(r""" +^ # beginning of the string +\s* # 0 or more space +if # an if +\s+ # 1 or more space +(?P # open the group val +\w+ # the group contain 1 or more alphanumeric characters +) # close the group +""", re.VERBOSE) + +p_else = re.compile(r""" +^ # beginning of the line +\s* # 0 or more space +else # +\s* # 0 or more space +""", re.VERBOSE) + +p_endif = re.compile(r""" +^ # beginning of the line +\s* # 0 or more space +endif # a endif +\s* # 0 or more space +""", re.VERBOSE) + +p_attribution = re.compile(r""" +^ # beginning of the line +(?P # open the group spaces +\s* # 0 or more space +) # close the group +(?P # open the group key +\w+ # the group contain 1 or more alphanumeric characters +) # close the group +\s* # 0 or more space +(?P # open the group method +\+? # 0 or 1 + += # One = +) # close the group +(?P # open the group value +.* # 0 or more any characters +) # close the group +""", re.VERBOSE) + +# ----- + +class CMakeFile(object): + + def __init__(self, the_root, root, dirs, files, f, module): + # + self.the_root = the_root + self.root = root + self.dirs = dirs + self.files = files + self.module = module + # + from os.path import join + self.amFile = join(root, f) + self.listsFile = join(root, "CMakeLists.txt") + # + self.parseFile() + # + return + + def parseFile(self): + + # -- + # Read the Makefile.am file + # -- + amFile = self.amFile + stream = open(amFile) + content = stream.read() + stream.close() + + # -- + # Replace the composed lines separated by "\\n" by an unique line + # -- + content = p_multiline.sub(r'', content) + + # -- + content = content.replace("-no-undefined -version-info=0:0:0", "") + content = content.replace("-include SALOMEconfig.h", "") + + # -- + cas_list = ["TKV3d", "TKOpenGl"] + kernel_list = [ + "SalomeIDLKernel", + "SalomeHDFPersist", + "SalomeNS", + "SALOMELocalTrace", + "OpUtil", + "SalomeLifeCycleCORBA", + "SalomeCatalog", + "SalomeDSClient", + "with_loggerTraceCollector", + "SalomeContainer", + "SalomeResourcesManager", + "TOOLSDS", + "SalomeDSImpl", + "SalomeGenericObj", + "Registry", + "SalomeNotification", + "SALOMEBasics", + "SalomeLauncher", + ] + full_list = cas_list + kernel_list + for key in full_list: + content = content.replace("-l%s"%(key), "${%s}"%(key)) + pass + + # -- + # Split content in lines to treat each one separately + # -- + lines = content.split('\n') + + # -- + # newlines contains the lines of the future CMakeLists.txt file + # -- + newlines = [] + + # -- + # opened_ifs is used to deals with nested conditionnals + # -- + opened_ifs = [] + + # -- + # the __thedict__ dictionnary contains key, val + # of the Makefile.am file + # -- + self.__thedict__ = {} + + # -- + # Initialize file ... mainly includes other cmake files + # -- + self.initialize(newlines) + + # -- + # Do the job for each line + # -- + for line in lines: + self.treatLine(line, newlines, opened_ifs) + pass + + # -- + # Finalize file ... it is in here the cmake job is done + # -- + self.finalize(newlines) + + # -- + # Add a last CR at the end of the file + # -- + newlines.append('\n') + + # -- + # Concatenate newlines into content + # -- + content = '\n'.join(newlines) + + # -- + self.content = content + + # -- + return + + def initialize(self, newlines): + if self.root == self.the_root: + # -- + if self.module == "kernel": + newlines.append(""" + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPYTHON.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindHDF5.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindBOOST.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSWIG.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake) + """) + pass + else: + newlines.append(""" + SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR}) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake) + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindCAS.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQT4.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindOPENGL.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindVTK.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindQWT.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake) + """) + pass + # -- + if self.module == "kernel": + newlines.append(""" + SET(WITH_LOCAL 1) + SET(WITH_BATCH 1) + set(VERSION 4.1.3) + set(XVERSION 0x040103) + """) + elif self.module == "gui": + newlines.append(""" + SET(GUI_ENABLE_CORBA ${CORBA_GEN}) + SET(ENABLE_VTKVIEWER ON) + SET(ENABLE_SALOMEOBJECT ON) + SET(ENABLE_OCCVIEWER ON) + SET(ENABLE_GLVIEWER ON) + SET(ENABLE_PLOT2DVIEWER ON) + SET(ENABLE_PYCONSOLE ON) + SET(ENABLE_SUPERVGRAPHVIEWER ON) + # SET(ENABLE_QXGRAPHVIEWER ON) + """) + pass + pass + return + + def treatLine(self, line, newlines, opened_ifs): + + # -- + # Print the comment above the line itself + # -- + if line.find('#') >= 0: + fields = line.split('#') + line = fields[0] + comment = '#'.join([''] + fields[1:]) + newlines.append(comment) + if len(line) == 0: + return + pass + + # -- + # If the line begins with 'include', just comment it + # -- + if line.find("include") == 0: + newlines.append("# " + line) + return + + # -- + # If the line begins with '-include', just comment it + # -- + if line.find("-include") == 0: + newlines.append("# " + line) + return + + # -- + # If the line is a definition of a make rule, just comment it + # -- + if line.count(':') == 1: + newlines.append("# " + line) + return + + # -- + # A particuliar case + # -- + if line.find('install-exec-local:') == 0: + newlines.append("# " + line) + return + + # -- + # If the line begin by a tabulation, consider it's a makefile command and comment it + # -- + if line.find("\t") == 0: + newlines.append("# " + line) + return + + # -- + # Replace the $(TOTO) by ${TOTO} + # Replace the @TOTO@ by ${TOTO} + # -- + line = p_dollar.sub(r"${\1}", line) + line = p_arobas.sub(r"${\1}", line) + + # -- + line = line.replace(r"${top_builddir}", r"${CMAKE_BINARY_DIR}") + line = line.replace(r"${top_srcdir}", r"${CMAKE_SOURCE_DIR}") + line = line.replace(r"${srcdir}", r"${CMAKE_CURRENT_SOURCE_DIR}") + line = line.replace(r"${builddir}", r"${CMAKE_CURRENT_BINARY_DIR}") + + # -- + # Check if the line is a 'if' condition + # If yes, replace it by a cmake grammar + # -- + match = p_if.match(line) + if match: + theif = match.group("val") + line = p_if.sub(r"IF(%s)"%(theif), line) + opened_ifs.append(theif) + newlines.append(line) + return + + # -- + # Check if the line is a 'else' condition + # If yes, replace it by a cmake grammar + # -- + match = p_else.match(line) + if match: + line = "ELSE(%s)"%(opened_ifs[-1]) + newlines.append(line) + return + + # -- + # Check if the line is a 'endif' condition + # If yes, replace it by a cmake grammar + # -- + match = p_endif.match(line) + if match: + line = "ENDIF(%s)"%(opened_ifs[-1]) + opened_ifs[-1:] = [] + newlines.append(line) + return + + # -- + # Check if the line is an attribution '=' or '+=' + # -- + match = p_attribution.match(line) + if match: + self.treatAttribution(match, newlines) + return + + # -- + newlines.append(line) + + # -- + return + + def treatAttribution(self, match, newlines): + + spaces = match.group("spaces") + key = match.group("key") + method = match.group("method") + value = match.group("value") + # print [spaces, key, method, value] + + # -- + # Open cmake SET command + # -- + newlines.append(spaces + "SET(" + key) + + # -- + # If method is '+=', put the previous definition as first value + # -- + if method == "+=": + newlines.append("%s ${%s}"%(spaces, key)) + pass + + # -- + fields = value.split() + for i in range(len(fields)): + newlines.append("%s %s"%(spaces, fields[i])) + pass + + # -- + if method == "+=": + # -- + # The try: except KeyError is here if the += + # is an error which occurs in salome ... + # -- + try: + self.__thedict__[key] += fields[:] + except KeyError: + self.__thedict__[key] = fields[:] + pass + pass + else: + self.__thedict__[key] = fields[:] + pass + + # -- + # Close cmake SET command + # -- + + newlines.append("%s)"%(spaces)) + + return + + def finalize(self, newlines): + + # -- + # Convert the .in files in build dir + # -- + for f in self.files: + if f[-3:] == ".in": + if f == "sstream.in": + continue + if f == "SALOMEconfig.ref.in": + out = "SALOMEconfig.h" + else: + out = f[:-3] + pass + newlines.append(r''' + SET(input ${CMAKE_CURRENT_SOURCE_DIR}/%s) + '''%(f)) + newlines.append(r''' + SET(output ${CMAKE_CURRENT_BINARY_DIR}/%s) + '''%(out)) + newlines.append(r''' + MESSAGE(STATUS "Creation of ${output}") + CONFIGURE_FILE(${input} ${output}) + ''') + pass + pass + + # -- + # convert the SUBDIRS in cmake grammar + # -- + if self.__thedict__.has_key("SUBDIRS"): + newlines.append(r''' + FOREACH(dir ${SUBDIRS}) + ADD_SUBDIRECTORY(${dir}) + ENDFOREACH(dir ${SUBDIRS}) + ''') + pass + + # -- + # -- + for key in ["lib_LTLIBRARIES", "noinst_LTLIBRARIES", "salomepyexec_LTLIBRARIES"]: + if self.__thedict__.has_key(key): + self.addLibTarget(key, newlines) + pass + pass + + # -- + # -- + for key in ["bin_PROGRAMS"]: + if self.__thedict__.has_key(key): + self.addBinTarget(key, newlines) + pass + pass + + # -- + # -- + if self.__thedict__.has_key("BASEIDL_FILES"): + if not self.__thedict__.has_key("IDL_FILES"): + self.__thedict__["IDL_FILES"] = self.__thedict__["BASEIDL_FILES"] + newlines.append(''' + SET(IDL_FILES ${BASEIDL_FILES}) + ''') + pass + pass + + # -- + # -- + + key = "IDL_FILES" + if self.__thedict__.has_key(key): + newlines.append(''' + FOREACH(input ${IDL_FILES}) + STRING(REGEX REPLACE ".idl" "" base ${input}) + SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc) + SET(outputs ${src}) + SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc) + SET(outputs ${outputs} ${dynsrc}) + ADD_CUSTOM_COMMAND( + OUTPUT ${outputs} + COMMAND ${OMNIORB_IDL} ${IDLCXXFLAGS} ${OMNIORB_IDLCXXFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${input} + MAIN_DEPENDENCY ${input} + ) + install(FILES ${input} DESTINATION idl/salome) + SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh) + install(FILES ${IDL_HEADER} DESTINATION include/salome) + INSTALL(CODE "SET(IDL_FILE ${input})") + INSTALL(CODE "SET(DIR lib/${PYTHON_VERSION}/site-packages/salome)") + INSTALL(CODE "SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})") + INSTALL(CODE "SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL_PYTHON})") + INSTALL(CODE "SET(IDLPYFLAGS ${IDLPYFLAGS})") + ''') + if self.module == "kernel": + newlines.append(''' + INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake) + ''') + else: + newlines.append(''' + INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_python_from_idl.cmake) + ''') + pass + newlines.append(''' + ENDFOREACH(input ${IDL_FILES}) + ''') + pass + + # -- + # -- + if self.__thedict__.has_key("SWIG_SRC"): + newlines.append(''' + SET(SWIG_SOURCES ${SWIG_SRC}) + ''') + self.__thedict__["SWIG_SOURCES"] = self.__thedict__["SWIG_SRC"] + pass + + # -- + # -- + if self.__thedict__.has_key("SWIG_SOURCES"): + newlines.append(''' + IF(SWIG_SOURCES MATCHES ";") + STRING(REGEX REPLACE ";.*" "" SWIG_SOURCES_FIRST "${SWIG_SOURCES}") + ELSE(SWIG_SOURCES MATCHES ";") + SET(SWIG_SOURCES_FIRST "${SWIG_SOURCES}") + ENDIF(SWIG_SOURCES MATCHES ";") + ADD_CUSTOM_COMMAND( + OUTPUT ${build_srcs} + COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} ${MY_SWIG_FLAGS} -o ${build_srcs} ${CMAKE_CURRENT_SOURCE_DIR}/${SWIG_SOURCES_FIRST} + MAIN_DEPENDENCY ${SWIG_SOURCES} + ) + ''') + pass + + # -- + # -- + key = "MOC_FILES" + if self.__thedict__.has_key(key): + newlines.append(''' + FOREACH(output ${MOC_FILES}) + STRING(REGEX REPLACE _moc.cxx .h input ${output}) + SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input}) + SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output}) + ADD_CUSTOM_COMMAND( + OUTPUT ${output} + COMMAND ${QT_MOC_EXECUTABLE} ${MOC_FLAGS} ${input} -o ${output} + MAIN_DEPENDENCY ${input} + ) + ENDFOREACH(output ${MOC_FILES}) + ''') + pass + + # -- + # -- + key = "QRC_FILES" + if self.__thedict__.has_key(key): + newlines.append(''' + FOREACH(output ${QRC_FILES}) + STRING(REGEX REPLACE "qrc_" "" input ${output}) + STRING(REGEX REPLACE ".cxx" ".qrc" input ${input}) + STRING(REGEX REPLACE ".qrc" "" name ${input}) + SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input}) + SET(output ${CMAKE_CURRENT_BINARY_DIR}/${output}) + ADD_CUSTOM_COMMAND( + OUTPUT ${output} + COMMAND ${QT_RCC_EXECUTABLE} ${input} -o ${output} -name ${name} + MAIN_DEPENDENCY ${input} + ) + ENDFOREACH(output ${QRC_FILES}) + ''') + pass + + # -- + # -- + key = "SIP_FILES" + if self.__thedict__.has_key(key): + newlines.append(''' + FOREACH(input ${SIP_FILES}) + SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input}) + SET(output) + FOREACH(out ${SIP_SRC}) + SET(output ${output} ${CMAKE_CURRENT_BINARY_DIR}/${out}) + ENDFOREACH(out ${SIP_SRC}) + ADD_CUSTOM_COMMAND( + OUTPUT ${output} + COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${input} + MAIN_DEPENDENCY ${input} + ) + ENDFOREACH(input ${SIP_FILES}) + ''') + pass + + # -- + # Treat the install targets + # -- + d = { + "salomeadmux_DATA" : "salome_adm/unix", + "dist_salomeadmux_DATA" : "salome_adm/unix", + "dist_salome_cmake_DATA" : "salome_adm/cmake_files", + "dist_salomem4_DATA" : "salome_adm/unix/config_files", + "dist_salome4depr_DATA" : "salome_adm/unix/config_files/DEPRECATED", + "dist_admlocalm4_DATA" : "adm_local/unix/config_files", + "salomeinclude_DATA" : "include/salome", + "salomeinclude_HEADERS" : "include/salome", + "dist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), + "nodist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), + "dist_salomescript_SCRIPTS" : "bin/salome", + "dist_salomescript_DATA" : "bin/salome", + "dist_salomescript_PYTHON" : "bin/salome", + "nodist_salomescript_DATA" : "bin/salome", + "salomepython_PYTHON" : "lib/python2.5/site-packages/salome", + "nodist_salomepython_PYTHON" : "lib/python2.5/site-packages/salome", + "sharedpkgpython_PYTHON" : "lib/python2.5/site-packages/salome/shared_modules", + } + for key, value in d.items(): + if self.__thedict__.has_key(key): + self.addInstallTarget(key, value, newlines) + pass + pass + + # -- + return + + def setLibAdd(self, newlines): + # -- + newlines.append(r''' + SET(libadd) + ''') + # -- + newlines.append(r''' + IF(WINDOWS) + SET(libadd ${libadd} Userenv.lib Ws2_32.lib) + ELSE(WINDOWS) + SET(libadd ${libadd} -ldl -lpthread) + ENDIF(WINDOWS) + ''') + # -- + newlines.append(r''' + FOREACH(lib ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + GET_FILENAME_COMPONENT(ext ${lib} EXT) + IF(ext STREQUAL .la) + GET_FILENAME_COMPONENT(lib ${lib} NAME_WE) + STRING(REPLACE "lib" "" lib ${lib}) + ENDIF(ext STREQUAL .la) + IF(WINDOWS) + SET(vars -Xlinker -export-dynamic -module -Wl,-E) + FOREACH(v ${vars}) + IF(lib STREQUAL v) + SET(lib) + ENDIF(lib STREQUAL v) + ENDFOREACH(v ${vars}) + ENDIF(WINDOWS) + SET(libadd ${libadd} ${lib}) + ENDFOREACH(lib ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + TARGET_LINK_LIBRARIES(${name} ${PTHREADS_LIBRARY} ${libadd}) + ''') + return + + def setCompilationFlags(self, newlines): + newlines.append(r''' + SET(var) + SET(var ${var} ${PLATFORM_CPPFLAGS}) + SET(var ${var} ${PTHREADS_INCLUDES}) + SET(var ${var} ${${amname}_CPPFLAGS}) + SET(var ${var} ${${amname}_CXXFLAGS}) + SET(flags) + FOREACH(f ${var}) + SET(flags "${flags} ${f}") + ENDFOREACH(f ${var}) + SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}") + ''') + return + + def addLibTarget(self, key, newlines): + newlines.append(r''' + FOREACH(amname ${%s}) + '''%(key)) + # -- + # Replace .la by _la ... + # -- + newlines.append(r''' + STRING(REPLACE .la _la amname ${amname}) + ''') + # -- + # Remove the _la for the cmake name + # -- + newlines.append(r''' + STRING(LENGTH ${amname} len) + MATH(EXPR newlen "${len}-3") + STRING(SUBSTRING ${amname} 0 ${newlen} name) + ''') + # -- + # Does the target begins with lib ?? + # If yes, remove lib at beginning for cmake name + # -- + newlines.append(r''' + STRING(REGEX MATCH "^lib" BEGIN_WITH_lib ${name}) + IF(BEGIN_WITH_lib) + STRING(LENGTH ${name} len) + MATH(EXPR newlen "${len}-3") + STRING(SUBSTRING ${name} 3 ${newlen} name) + ENDIF(BEGIN_WITH_lib) + ''') + # -- + # Does the target is an idl library + # -- + newlines.append(r''' + STRING(REGEX MATCH "IDL" ISIDL ${name}) + ''') + # -- + # Set the type of the library + # -- + newlines.append(r''' + IF(ISIDL) + IF(WINDOWS) + SET(type STATIC) + ELSE(WINDOWS) + SET(type SHARED) + ENDIF(WINDOWS) + ELSE(ISIDL) + SET(type SHARED) + ENDIF(ISIDL) + ''') + # -- + # Set sources for the library + # -- + newlines.append(r''' + SET(srcs) + SET(srcs ${srcs} ${${amname}_SOURCES}) + SET(srcs ${srcs} ${dist_${amname}_SOURCES}) + SET(build_srcs) + FOREACH(f ${nodist_${amname}_SOURCES} ${BUILT_SOURCES}) + SET(build_srcs ${build_srcs} ${CMAKE_CURRENT_BINARY_DIR}/${f}) + ENDFOREACH(f ${nodist_${amname}_SOURCES}) + SET(srcs ${build_srcs} ${srcs}) + ''') + # -- + # Add the library to cmake + # -- + newlines.append(r''' + ADD_LIBRARY(${name} ${type} ${srcs}) + ''') + # -- + # The compilation flags + # -- + self.setCompilationFlags(newlines) + # -- + newlines.append(r''' + SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION 0.0.0 SOVERSION 0) + ''') + # -- + from os.path import basename + upper_name = basename(self.root).upper() + # -- + newlines.append(r''' + SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL %s_EXPORTS) + '''%(upper_name)) + newlines.append(r''' + IF(name STREQUAL SalomeLauncher) + SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SALOME%s_EXPORTS) + ENDIF(name STREQUAL SalomeLauncher) + '''%(upper_name)) + newlines.append(r''' + IF(name STREQUAL SalomeResourcesManager) + SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SALOME%s_EXPORTS) + ENDIF(name STREQUAL SalomeResourcesManager) + '''%(upper_name)) + # -- + self.setLibAdd(newlines) + # -- + newlines.append(r''' + IF(name STREQUAL SalomeHDFPersist) + IF(WINDOWS) + SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD") + ENDIF(WINDOWS) + ENDIF(name STREQUAL SalomeHDFPersist) + ''') + # -- + if key != "noinst_LTLIBRARIES": + newlines.append(r''' + IF(BEGIN_WITH_lib) + INSTALL(TARGETS ${name} DESTINATION lib/salome) + IF(name STREQUAL SalomePyQt) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION lib/salome RENAME ${name}.so) + ENDIF(name STREQUAL SalomePyQt) + ELSE(BEGIN_WITH_lib) + IF(WINDOWS) + INSTALL(TARGETS ${name} DESTINATION lib/python2.5/site-packages/salome) + ELSE(WINDOWS) + GET_TARGET_PROPERTY(version ${name} VERSION) + GET_TARGET_PROPERTY(soversion ${name} SOVERSION) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python2.5/site-packages/salome RENAME ${name}.so.${version}) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python2.5/site-packages/salome RENAME ${name}.so.${soversion}) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python2.5/site-packages/salome RENAME ${name}.so) + ENDIF(WINDOWS) + ENDIF(BEGIN_WITH_lib) + ''') + pass + # -- + newlines.append(r''' + ENDFOREACH(amname ${%s}) + '''%(key)) + # -- + return + + def addBinTarget(self, key, newlines): + # -- + newlines.append(r''' + FOREACH(amname ${bin_PROGRAMS}) + ''') + # -- + newlines.append(r''' + SET(name "${amname}_exe") + SET(srcs ${${amname}_SOURCES} ${dist_${amname}_SOURCES}) + ADD_EXECUTABLE(${name} ${srcs}) + ''') + # -- + self.setCompilationFlags(newlines) + # -- + self.setLibAdd(newlines) + # -- + newlines.append(r''' + IF(WINDOWS) + INSTALL(TARGETS ${name} DESTINATION bin/salome) + INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/bin/salome/${name}.exe DESTINATION bin/salome RENAME ${amname}.exe) + INSTALL(CODE "FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/bin/salome/${name}.exe)") + ELSE(WINDOWS) + SET(PERMS) + SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE) + SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE) + SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name} DESTINATION bin/salome PERMISSIONS ${PERMS} RENAME ${amname}) + ENDIF(WINDOWS) + ''') + # -- + newlines.append(r''' + ENDFOREACH(amname ${bin_PROGRAMS}) + ''') + # -- + return + + def addInstallTarget(self, key, destination, newlines): + newlines.append(r"FOREACH(f ${%s})"%(key)) + newlines.append(r''' + SET(DEST %s) + '''%(destination)) + newlines.append(r''' + STRING(COMPARE EQUAL ${f} SALOMEconfig.h.in test_SALOMEconfig.h.in) + IF(test_SALOMEconfig.h.in) + INSTALL(FILES SALOMEconfig.ref.in DESTINATION ${DEST} RENAME SALOMEconfig.h.in) + ELSE(test_SALOMEconfig.h.in) + SET(dummy dummy-NOTFOUND) + MARK_AS_ADVANCED(dummy) + # FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEST}/${f}) + FIND_FILE(dummy ${f} PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH) + IF(dummy) + ''') + if key in ['dist_salomescript_SCRIPTS']: + newlines.append(r''' + SET(PERMS) + SET(PERMS ${PERMS} OWNER_READ OWNER_WRITE OWNER_EXECUTE) + SET(PERMS ${PERMS} GROUP_READ GROUP_EXECUTE) + SET(PERMS ${PERMS} WORLD_READ WORLD_EXECUTE) + INSTALL(FILES ${f} DESTINATION ${DEST} PERMISSIONS ${PERMS}) + ''') + else: + newlines.append(r''' + INSTALL(FILES ${f} DESTINATION ${DEST}) + ''') + pass + newlines.append(r''' + ELSE(dummy) + GET_FILENAME_COMPONENT(ext ${f} EXT) + IF(ext STREQUAL .qm) + STRING(REGEX REPLACE .qm .ts input ${f}) + SET(input ${CMAKE_CURRENT_SOURCE_DIR}/resources/${input}) + SET(output ${CMAKE_CURRENT_BINARY_DIR}/${f}) + # ADD_CUSTOM_COMMAND( + # OUTPUT ${output} + # COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output} + # MAIN_DEPENDENCY ${input} + # ) + EXECUTE_PROCESS(COMMAND ${QT_LRELEASE_EXECUTABLE} ${input} -qm ${output}) + ENDIF(ext STREQUAL .qm) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${DEST}) + ENDIF(dummy) + ENDIF(test_SALOMEconfig.h.in) + ''') + newlines.append(r"ENDFOREACH(f ${%s})"%(key)) + return + + def writeListsFile(self): + f = open(self.listsFile, "w") + f.write(self.content) + f.close() + return + + pass + +def convertAmFile(the_root, root, dirs, files, f, module): + cmake = CMakeFile(the_root, root, dirs, files, f, module) + cmake.writeListsFile() + return + +def usage(exit_status): + from sys import exit + from sys import argv + print "Usage: %s --module"%(argv[0]) + exit(exit_status) + return + +if __name__ == "__main__": + # + from sys import argv + if len(argv) != 2: + usage(1) + pass + # + module = argv[1] + if module.find('--') != 0: + usage(1) + pass + module = module[2:] + if len(module) == 0: + usage(1) + pass + # + from os import getcwd + the_root = getcwd() + # + from os import walk + for root, dirs, files in walk(the_root): + from os.path import basename + if basename(root) == "CVS": continue + for f in files: + from os.path import basename + if basename(f) == "Makefile.am": + convertAmFile(the_root, root, dirs, files, f, module) + pass + pass + pass + # + pass diff --git a/salome_adm/cmake_files/install_python_from_idl.cmake b/salome_adm/cmake_files/install_python_from_idl.cmake new file mode 100644 index 000000000..211765845 --- /dev/null +++ b/salome_adm/cmake_files/install_python_from_idl.cmake @@ -0,0 +1,5 @@ + +SET(FULLDIR ${CMAKE_INSTALL_PREFIX}/${DIR}) +FILE(MAKE_DIRECTORY ${FULLDIR}) +MESSAGE(STATUS "Compiling ${IDL_FILE} into ${FULLDIR}") +EXECUTE_PROCESS(COMMAND ${OMNIORB_IDL_PYTHON} ${IDLPYFLAGS} -C${FULLDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_FILE}) -- 2.39.2