1 # Copyright (C) 2007-2016 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, or (at your option) any later version.
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. If just a file name is given, the source
42 # tree is first inspected. If not found there, the macro assumes the file will be built
43 # in the build tree (CMAKE_CURRENT_BINARY_DIR) thanks to some ADD_CUSTOM_COMMAND() call
45 # incdirs : additional include dirs for IDL staff
46 # linklibs : additional libraries the module to be linked to (optional)
48 # For example, to build CORBA staff from MyModule.idl for module MyModule
49 # (that depends only on SALOME KERNEL interfaces), use the following code:
52 # INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} ${KERNEL_INCLUDE_DIRS})
53 # OMNIORB_ADD_MODULE(SalomeIDLMyModule MyModule.idl ${KERNEL_ROOT_DIR}/idl/salome ${KERNEL_SalomeIDLKernel})
54 # INSTALL(TARGETS SalomeIDLMyModule EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
56 # This macro uses the following variables:
57 # - From FindOmniORB.cmake
58 # OMNIORB_IDL : the path to the omniidl tool
59 # OMNIORB_IDLCXXFLAGS : the options to give to omniidl generator for C++ backend
60 # OMNIORB_DEFINITIONS : additional compile options for C++
61 # - From FindOmniORBPy.cmake
62 # OMNIORB_IDLPYFLAGS : the options to give to omniidl generator for Python backend
63 # OMNIORB_PYTHON_BACKEND : Python backend
65 # The macro automatically adds a target "omniorb_module_<module>" which can be used to set up
66 # dependencies on the generation of the files produced by omniidl (typically the header files).
69 # 1. Replace hardcoded dirpaths bin/salome, idl/salome, etc by corresponding configuration options.
70 # 2. Revise/improve OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL macro usage.
71 # 3. Add proper handling of INCLUDE_DIRECTORIES to minimize this macro usage in target CMakeLists.txt files.
73 #----------------------------------------------------------------------------
74 MACRO(OMNIORB_ADD_MODULE module idlfiles incdirs)
75 # process additional libraries the module to be linked to
76 SET(_linklibs ${OMNIORB_LIBRARIES})
78 SET(_linklibs ${_linklibs} ${_arg})
83 # module produced files
85 # type of the libraries: SHARED for Linux, STATIC for Windows
90 IF(NOT WIN32 AND (_type STREQUAL STATIC))
91 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
94 # add additional include dirs to the C++ and Python backend options
95 SET(_cxx_flags ${OMNIORB_IDLCXXFLAGS})
96 SET(_py_flags "${OMNIORB_IDLPYFLAGS}")
97 FOREACH(_f ${incdirs})
98 LIST(APPEND _cxx_flags "-I${_f}")
99 LIST(APPEND _py_flags "-I${_f}")
102 FOREACH(_input ${idlfiles})
103 GET_FILENAME_COMPONENT(_base ${_input} NAME_WE)
104 GET_FILENAME_COMPONENT(_path ${_input} PATH)
106 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
107 SET(_input_cmd ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
109 SET(_input_cmd ${CMAKE_CURRENT_BINARY_DIR}/${_input})
112 SET(_input_cmd ${_input})
115 SET(_inc ${CMAKE_CURRENT_BINARY_DIR}/${_base}.hh)
116 SET(_src ${CMAKE_CURRENT_BINARY_DIR}/${_base}SK.cc)
117 SET(_dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${_base}DynSK.cc)
119 LIST(APPEND _sources ${_src})
120 LIST(APPEND _sources ${_dynsrc})
121 SET(_outputs ${_inc} ${_src} ${_dynsrc})
122 LIST(APPEND _all_outputs ${_outputs})
124 ADD_CUSTOM_COMMAND(OUTPUT ${_outputs}
125 COMMAND ${OMNIORB_IDL_COMPILER} ${_cxx_flags} ${_input_cmd}
126 DEPENDS ${_input_cmd})
128 INSTALL(FILES ${_input_cmd} DESTINATION idl/salome)
129 INSTALL(FILES ${_inc} DESTINATION include/salome)
131 IF(OMNIORB_PYTHON_BACKEND)
132 STRING(REPLACE ";" " " _tmp "${_py_flags}")
133 INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${_tmp}\" \"${_input_cmd}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
137 ADD_LIBRARY(${module} ${_type} ${_sources})
138 TARGET_LINK_LIBRARIES(${module} ${_linklibs})
139 SET_TARGET_PROPERTIES(${module} PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS}")
140 ADD_CUSTOM_TARGET(omniorb_module_${module} DEPENDS ${_all_outputs})
141 ENDMACRO(OMNIORB_ADD_MODULE)