Salome HOME
Unify of BLSURFPLUGIN documentation.
[modules/kernel.git] / salome_adm / cmake_files / deprecated / UseOMNIORB.cmake
1 # Copyright (C) 2007-2013  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 "SET(INSTALL_PYIDL_DIR lib/python${PYTHON_VERSION}/site-packages/salome)") # R1 CHECK
21   IF(WINDOWS)
22     INSTALL(CODE "SET(INSTALL_PYIDL_DIR bin/salome)") # R1 CHECK
23   ENDIF(WINDOWS)
24
25 INSTALL(CODE "MACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL MYOMNIORBIDLPYTHON MYIDLPYFLAGS MYIDLFILE MYFULLDIR)
26   FILE(MAKE_DIRECTORY \${MYFULLDIR})
27   STRING(REPLACE \" \" \";\" MYIDLPYFLAGS2 \${MYIDLPYFLAGS})
28   MESSAGE(STATUS \"Compiling \${MYIDLFILE} into \${MYFULLDIR}\")
29   EXECUTE_PROCESS(COMMAND \${MYOMNIORBIDLPYTHON} \${MYIDLPYFLAGS2} -C\${MYFULLDIR} \${MYIDLFILE})
30 ENDMACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL)")
31
32 # This MACRO uses the following vars
33 # - OMNIORB_IDL : the idl tool (given by default by FindOMNIORB.cmake)
34 # - OMNIORB_IDLCXXFLAGS : the options (include excluded) to give to omniidl generator (given by default by FindOMNIORB.cmake)
35 #
36 # MYMODULE is a string that will be used to create a target with sources containing *.cc coming from the compilation of ${MYIDLFILES}
37 # MYIDLFILES containing all idl files to be compiled.
38 # MYIDLCXXFLAGS containing all directories (only directories) where to find *.idl which depend ${MYIDLFILES}.
39 # TYPE contains type of the library 
40 MACRO(OMNIORB_ADD_MODULE MYMODULE MYIDLFILES MYIDLCXXFLAGS TYPE)
41   SET(MYSOURCES)
42   FOREACH(input ${MYIDLFILES})
43     GET_FILENAME_COMPONENT(base ${input} NAME_WE)
44 #    STRING(REGEX REPLACE ".idl" "" base ${input})
45     SET(OMNIORB_IDLCXXFLAGS2 "${OMNIORB_IDLCXXFLAGS}")
46     SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc)
47     SET(MYSOURCES ${MYSOURCES} ${src})
48     SET(outputs ${src})
49     SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc)
50     SET(MYSOURCES ${MYSOURCES} ${dynsrc})
51     SET(outputs ${outputs} ${dynsrc})
52     SET(inc ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
53     SET(outputs ${outputs} ${inc})
54     GET_FILENAME_COMPONENT(path ${input} PATH)
55     IF(NOT path)
56       SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
57     ENDIF(NOT path)
58     SET(flags ${OMNIORB_IDLCXXFLAGS2})
59     STRING(REGEX MATCH "-bcxx" ISBCXX ${flags})
60     IF(NOT ISBCXX)
61       SET(flags -bcxx ${flags})
62     ENDIF(NOT ISBCXX)
63     FOREACH(f ${MYIDLCXXFLAGS})
64       SET(flags ${flags} "-I${f}")
65     ENDFOREACH(f ${MYIDLCXXFLAGS})
66     ADD_CUSTOM_COMMAND(OUTPUT ${outputs}
67       COMMAND ${OMNIORB_IDL} ${flags} ${input}
68       MAIN_DEPENDENCY ${input})
69     SET(IDLPYFLAGS ${flags})
70     INSTALL(FILES ${input} DESTINATION idl/salome)
71     SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh)
72     INSTALL(FILES ${IDL_HEADER} DESTINATION include/salome)
73     SET(flags)
74     FOREACH(f ${MYIDLCXXFLAGS})
75       SET(flags "${flags} -I${f}")
76     ENDFOREACH(f ${MYIDLCXXFLAGS})
77     STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags})
78     IF(NOT ISBPYTHON)
79       SET(flags "-bpython ${flags}")
80     ENDIF(NOT ISBPYTHON)
81     SET(IDLPYFLAGS ${flags})
82     STRING(REPLACE "\\" "/" IDLPYFLAGS ${IDLPYFLAGS})
83     INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_PYTHON}\" \"${IDLPYFLAGS}\" \"${input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
84   ENDFOREACH(input ${MYIDLFILES})
85   ADD_LIBRARY(${MYMODULE} ${TYPE} ${MYSOURCES})
86
87 ENDMACRO(OMNIORB_ADD_MODULE)