1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 SET(INSTALL_PYIDL_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/salome) # R1 CHECK
23 SET(INSTALL_PYIDL_DIR bin/salome) # R1 CHECK
26 MACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL MYOMNIORBIDLPYTHON MYIDLPYFLAGS MYIDLFILE MYFULLDIR)
27 FILE(MAKE_DIRECTORY \${MYFULLDIR})
28 STRING(REPLACE \" \" \";\" MYIDLPYFLAGS2 \${MYIDLPYFLAGS})
29 MESSAGE(STATUS \"Compiling \${MYIDLFILE} into \${MYFULLDIR}\")
30 EXECUTE_PROCESS(COMMAND \${MYOMNIORBIDLPYTHON} \${MYIDLPYFLAGS2} -C\${MYFULLDIR} \${MYIDLFILE})
31 ENDMACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL)
34 # This MACRO uses the following vars
35 # - OMNIORB_IDL : the idl tool (given by default by FindOMNIORB.cmake)
36 # - OMNIORB_IDLCXXFLAGS : the options (include excluded) to give to omniidl generator (given by default by FindOMNIORB.cmake)
38 # MYMODULE is a string that will be used to create a target with sources containing *.cc coming from the compilation of ${MYIDLFILES}
39 # MYIDLFILES containing all idl files to be compiled.
40 # MYIDLCXXFLAGS containing all directories (only directories) where to find *.idl which depend ${MYIDLFILES}.
41 # TYPE contains type of the library
42 MACRO(OMNIORB_ADD_MODULE MYMODULE MYIDLFILES MYIDLCXXFLAGS TYPE)
44 FOREACH(input ${MYIDLFILES})
45 GET_FILENAME_COMPONENT(base ${input} NAME_WE)
46 # STRING(REGEX REPLACE ".idl" "" base ${input})
47 SET(OMNIORB_IDLCXXFLAGS2 "${OMNIORB_IDLCXXFLAGS}")
48 SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc)
49 SET(MYSOURCES ${MYSOURCES} ${src})
51 SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc)
52 SET(MYSOURCES ${MYSOURCES} ${dynsrc})
53 SET(outputs ${outputs} ${dynsrc})
54 SET(inc ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
55 SET(outputs ${outputs} ${inc})
56 GET_FILENAME_COMPONENT(path ${input} PATH)
58 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
60 SET(flags ${OMNIORB_IDLCXXFLAGS2})
61 STRING(REGEX MATCH "-bcxx" ISBCXX ${flags})
63 SET(flags -bcxx ${flags})
65 FOREACH(f ${MYIDLCXXFLAGS})
66 SET(flags ${flags} "-I${f}")
67 ENDFOREACH(f ${MYIDLCXXFLAGS})
68 ADD_CUSTOM_COMMAND(OUTPUT ${outputs}
69 COMMAND ${OMNIORB_IDL_COMPILER} ${flags} ${input}
70 MAIN_DEPENDENCY ${input})
71 SET(IDLPYFLAGS ${flags})
72 INSTALL(FILES ${input} DESTINATION idl/salome)
73 SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
74 INSTALL(FILES ${IDL_HEADER} DESTINATION include/salome)
76 FOREACH(f ${MYIDLCXXFLAGS})
77 SET(flags "${flags} -I${f}")
78 ENDFOREACH(f ${MYIDLCXXFLAGS})
79 STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags})
81 SET(flags "-bpython ${flags}")
83 SET(IDLPYFLAGS ${flags})
84 STRING(REPLACE "\\" "/" IDLPYFLAGS ${IDLPYFLAGS})
85 IF(OMNIORB_PYTHON_BACKEND)
86 SET(IDLPYFLAGS "${IDLPYFLAGS} -p${OMNIORB_PYTHON_BACKEND}")
87 INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${IDLPYFLAGS}\" \"${input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
88 ENDIF(OMNIORB_PYTHON_BACKEND)
89 ENDFOREACH(input ${MYIDLFILES})
90 ADD_LIBRARY(${MYMODULE} ${TYPE} ${MYSOURCES})
92 ENDMACRO(OMNIORB_ADD_MODULE)