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 #----------------------------------------------------------------------------
35 # OMNIORB_ADD_MODULE macro: generate CORBA wrappings for a module.
37 # USAGE: OMNIORB_ADD_MODULE(module idlfiles incdirs [linklibs])
40 # module : module name
41 # idlfiles : list of IDL files to be compiled into module
42 # incdirs : additional include dirs for IDL staff
43 # linklibs : additional libraries the module to be linked to (optional)
45 # For example, to build CORBA staff from MyModule.idl for module MyModule
46 # (that depends only on SALOME KERNEL interfaces), use the following code:
49 # INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} ${KERNEL_INCLUDE_DIRS})
50 # OMNIORB_ADD_MODULE(SalomeIDLMyModule MyModule.idl ${KERNEL_ROOT_DIR}/idl/salome ${KERNEL_SalomeIDLKernel})
51 # INSTALL(TARGETS SalomeIDLMyModule EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
53 # This macro uses the following variables:
54 # - From FindOmniORB.cmake
55 # OMNIORB_IDL : the path to the omniidl tool
56 # OMNIORB_IDLCXXFLAGS : the options to give to omniidl generator for C++ backend
57 # OMNIORB_DEFINITIONS : additional compile options for C++
58 # - From FindOmniORBPy.cmake
59 # OMNIORB_IDLPYFLAGS : the options to give to omniidl generator for Python backend
60 # OMNIORB_PYTHON_BACKEND : Python backend
63 # 1. Replace hardcoded dirpaths bin/salome, idl/salome, etc by corresponding configuration options.
64 # 2. Revise/improve OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL macro usage.
65 # 3. Add proper handling of INCLUDE_DIRECTORIES to minimize this macro usage in target CMakeLists.txt files.
67 #----------------------------------------------------------------------------
68 MACRO(OMNIORB_ADD_MODULE module idlfiles incdirs)
69 # process additional libraries the module to be linked to
70 SET(_linklibs ${OMNIORB_LIBRARIES})
72 SET(_linklibs ${_linklibs} ${_arg})
77 # type of the libraries: SHARED for Linux, STATIC for Windows
82 # add additional include dirs to the C++ and Python backend options
83 SET(_cxx_flags ${OMNIORB_IDLCXXFLAGS})
84 SET(_py_flags "${OMNIORB_IDLPYFLAGS}")
85 FOREACH(_f ${incdirs})
86 LIST(APPEND _cxx_flags "-I${_f}")
87 LIST(APPEND _py_flags "-I${_f}")
90 FOREACH(_input ${idlfiles})
91 GET_FILENAME_COMPONENT(_base ${_input} NAME_WE)
92 GET_FILENAME_COMPONENT(_path ${_input} PATH)
94 SET(_input ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
97 SET(_inc ${CMAKE_CURRENT_BINARY_DIR}/${_base}.hh)
98 SET(_src ${CMAKE_CURRENT_BINARY_DIR}/${_base}SK.cc)
99 SET(_dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${_base}DynSK.cc)
101 LIST(APPEND _sources ${_src})
102 LIST(APPEND _sources ${_dynsrc})
103 SET(_outputs ${_inc} ${_src} ${_dynsrc})
105 ADD_CUSTOM_COMMAND(OUTPUT ${_outputs}
106 COMMAND ${OMNIORB_IDL_COMPILER} ${_cxx_flags} ${_input}
107 MAIN_DEPENDENCY ${_input})
109 INSTALL(FILES ${_input} DESTINATION idl/salome)
110 INSTALL(FILES ${_inc} DESTINATION include/salome)
112 IF(OMNIORB_PYTHON_BACKEND)
113 STRING(REPLACE ";" " " _tmp "${_py_flags}")
114 INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${_tmp}\" \"${_input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
118 ADD_LIBRARY(${module} ${_type} ${_sources})
119 TARGET_LINK_LIBRARIES(${module} ${_linklibs})
120 SET_TARGET_PROPERTIES(${module} PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS}")
122 ENDMACRO(OMNIORB_ADD_MODULE)