Salome HOME
Merge from V6_main 11/02/2013
[modules/kernel.git] / salome_adm / cmake_files / UseOMNIORB.cmake
1 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 INSTALL( CODE "
21 SET(INSTALL_PYIDL_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/salome) # R1 CHECK
22 IF(WINDOWS)
23   SET(INSTALL_PYIDL_DIR bin/salome) # R1 CHECK
24 ENDIF(WINDOWS)
25
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)
32 ")
33
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)
37 #
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)
43   SET(MYSOURCES)
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})
50     SET(outputs ${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)
57     IF(NOT path)
58       SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
59     ENDIF(NOT path)
60     SET(flags ${OMNIORB_IDLCXXFLAGS2})
61     STRING(REGEX MATCH "-bcxx" ISBCXX ${flags})
62     IF(NOT ISBCXX)
63       SET(flags -bcxx ${flags})
64     ENDIF(NOT ISBCXX)
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)
75     SET(flags)
76     FOREACH(f ${MYIDLCXXFLAGS})
77       SET(flags "${flags} -I${f}")
78     ENDFOREACH(f ${MYIDLCXXFLAGS})
79     STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags})
80     IF(NOT ISBPYTHON)
81       SET(flags "-bpython ${flags}")
82     ENDIF(NOT ISBPYTHON)
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})
91
92 ENDMACRO(OMNIORB_ADD_MODULE)