From 4ca2ffe46b6653829ee8fcb97bcef039588c7e09 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 20 Aug 2013 10:01:40 +0000 Subject: [PATCH] CMake build procedure improvements: - CORBA staff --- idl/CMakeLists.txt | 2 +- salome_adm/cmake_files/FindOmniORB.cmake | 2 +- salome_adm/cmake_files/FindOmniORBPy.cmake | 2 +- salome_adm/cmake_files/UseOmniORB.cmake | 140 +++++++++++++-------- 4 files changed, 88 insertions(+), 58 deletions(-) diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 3ca0b8e87..3cb948304 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -73,7 +73,7 @@ ELSE(WINDOWS) SET(TYPE SHARED) ENDIF(WINDOWS) -OMNIORB_ADD_MODULE(SalomeIDLKernel "${SalomeIDLKernel_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" ${TYPE}) +OMNIORB_ADD_MODULE(SalomeIDLKernel "${SalomeIDLKernel_IDLSOURCES}" "${IDL_INCLUDE_DIRS}") ADD_DEFINITIONS(${COMMON_FLAGS}) TARGET_LINK_LIBRARIES(SalomeIDLKernel ${OMNIORB_LIBRARIES}) diff --git a/salome_adm/cmake_files/FindOmniORB.cmake b/salome_adm/cmake_files/FindOmniORB.cmake index 11504fa09..397b4b6c0 100644 --- a/salome_adm/cmake_files/FindOmniORB.cmake +++ b/salome_adm/cmake_files/FindOmniORB.cmake @@ -125,7 +125,7 @@ ELSE() SET( OMNIORB_VERSION "NOT-FOUND" ) ENDIF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h ) -SET(OMNIORB_IDLCXXFLAGS -Wba -nf) +SET(OMNIORB_IDLCXXFLAGS -bcxx -Wba -nf) SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS}) SET(IDL_CLN_H .hh) SET(IDL_SRV_H .hh) diff --git a/salome_adm/cmake_files/FindOmniORBPy.cmake b/salome_adm/cmake_files/FindOmniORBPy.cmake index a151c54a9..5484e2e4c 100644 --- a/salome_adm/cmake_files/FindOmniORBPy.cmake +++ b/salome_adm/cmake_files/FindOmniORBPy.cmake @@ -47,7 +47,7 @@ MARK_AS_ADVANCED(OMNIORB_PYTHON_BACKEND) SET(OMNIORB_IDLPYFLAGS -bpython) IF (OMNIORB_PYTHON_BACKEND) - SET(OMNIORB_IDLPYFLAGS "-p ${OMNIORB_PYTHON_BACKEND} ${OMNIORB_IDLPYFLAGS}") + LIST(APPEND OMNIORB_IDLPYFLAGS -p${OMNIORB_PYTHON_BACKEND}) ENDIF() SET(IDLPYFLAGS ${OMNIORB_IDLPYFLAGS}) diff --git a/salome_adm/cmake_files/UseOmniORB.cmake b/salome_adm/cmake_files/UseOmniORB.cmake index 1efa8b206..7d63d22f2 100644 --- a/salome_adm/cmake_files/UseOmniORB.cmake +++ b/salome_adm/cmake_files/UseOmniORB.cmake @@ -31,62 +31,92 @@ MACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL MYOMNIORBIDLPYTHON MYIDLPYFLAGS M ENDMACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL) ") -# This MACRO uses the following vars -# - OMNIORB_IDL : the idl tool (given by default by FindOMNIORB.cmake) -# - OMNIORB_IDLCXXFLAGS : the options (include excluded) to give to omniidl generator (given by default by FindOMNIORB.cmake) +#---------------------------------------------------------------------------- +# OMNIORB_ADD_MODULE macro: generate CORBA wrappings for a module. # -# MYMODULE is a string that will be used to create a target with sources containing *.cc coming from the compilation of ${MYIDLFILES} -# MYIDLFILES containing all idl files to be compiled. -# MYIDLCXXFLAGS containing all directories (only directories) where to find *.idl which depend ${MYIDLFILES}. -# TYPE contains type of the library -MACRO(OMNIORB_ADD_MODULE MYMODULE MYIDLFILES MYIDLCXXFLAGS TYPE) - SET(MYSOURCES) - FOREACH(input ${MYIDLFILES}) - GET_FILENAME_COMPONENT(base ${input} NAME_WE) -# STRING(REGEX REPLACE ".idl" "" base ${input}) - SET(OMNIORB_IDLCXXFLAGS2 "${OMNIORB_IDLCXXFLAGS}") - SET(src ${CMAKE_CURRENT_BINARY_DIR}/${base}SK.cc) - SET(MYSOURCES ${MYSOURCES} ${src}) - SET(outputs ${src}) - SET(dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${base}DynSK.cc) - SET(MYSOURCES ${MYSOURCES} ${dynsrc}) - SET(outputs ${outputs} ${dynsrc}) - SET(inc ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh) - SET(outputs ${outputs} ${inc}) - GET_FILENAME_COMPONENT(path ${input} PATH) - IF(NOT path) - SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${input}) - ENDIF(NOT path) - SET(flags ${OMNIORB_IDLCXXFLAGS2}) - STRING(REGEX MATCH "-bcxx" ISBCXX ${flags}) - IF(NOT ISBCXX) - SET(flags -bcxx ${flags}) - ENDIF(NOT ISBCXX) - FOREACH(f ${MYIDLCXXFLAGS}) - SET(flags ${flags} "-I${f}") - ENDFOREACH(f ${MYIDLCXXFLAGS}) - ADD_CUSTOM_COMMAND(OUTPUT ${outputs} - COMMAND ${OMNIORB_IDL_COMPILER} ${flags} ${input} - MAIN_DEPENDENCY ${input}) - SET(IDLPYFLAGS ${flags}) - INSTALL(FILES ${input} DESTINATION idl/salome) - SET(IDL_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${base}.hh) - INSTALL(FILES ${IDL_HEADER} DESTINATION include/salome) - SET(flags) - FOREACH(f ${MYIDLCXXFLAGS}) - SET(flags "${flags} -I${f}") - ENDFOREACH(f ${MYIDLCXXFLAGS}) - STRING(REGEX MATCH "-bpython" ISBPYTHON ${flags}) - IF(NOT ISBPYTHON) - SET(flags "-bpython ${flags}") - ENDIF(NOT ISBPYTHON) - SET(IDLPYFLAGS ${flags}) - STRING(REPLACE "\\" "/" IDLPYFLAGS ${IDLPYFLAGS}) +# USAGE: OMNIORB_ADD_MODULE(module idlfiles incdirs [linklibs]) +# +# ARGUMENTS: +# module : module name +# idlfiles : list of IDL files to be compiled into module +# incdirs : additional include dirs for IDL staff +# linklibs : additional libraries the module to be linked to (optional) +# +# For example, to build CORBA staff from MyModule.idl for module MyModule +# (that depends only on SALOME KERNEL interfaces), use the following code: +# +# INCLUDE(UseOmniORB) +# INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} ${KERNEL_INCLUDE_DIRS}) +# OMNIORB_ADD_MODULE(SalomeIDLMyModule MyModule.idl ${KERNEL_ROOT_DIR}/idl/salome ${KERNEL_SalomeIDLKernel}) +# INSTALL(TARGETS SalomeIDLMyModule EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) +# +# This macro uses the following variables: +# - From FindOmniORB.cmake +# OMNIORB_IDL : the path to the omniidl tool +# OMNIORB_IDLCXXFLAGS : the options to give to omniidl generator for C++ backend +# OMNIORB_DEFINITIONS : additional compile options for C++ +# - From FindOmniORBPy.cmake +# OMNIORB_IDLPYFLAGS : the options to give to omniidl generator for Python backend +# OMNIORB_PYTHON_BACKEND : Python backend +# +# TODO: +# 1. Replace hardcoded dirpaths bin/salome, idl/salome, etc by corresponding configuration options. +# 2. Revise/improve OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL macro usage. +# 3. Add proper handling of INCLUDE_DIRECTORIES to minimize this macro usage in target CMakeLists.txt files. +# +#---------------------------------------------------------------------------- +MACRO(OMNIORB_ADD_MODULE module idlfiles incdirs) + # process additional libraries the module to be linked to + SET(_linklibs ${OMNIORB_LIBRARIES}) + FOREACH(_arg ${ARGN}) + SET(_linklibs ${_linklibs} ${_arg}) + ENDFOREACH() + + # module sources + SET(_sources) + # type of the libraries: SHARED for Linux, STATIC for Windows + SET(_type SHARED) + IF(WINDOWS) + SET(_type STATIC) + ENDIF() + # add additional include dirs to the C++ and Python backend options + SET(_cxx_flags ${OMNIORB_IDLCXXFLAGS}) + SET(_py_flags "${OMNIORB_IDLPYFLAGS}") + FOREACH(_f ${incdirs}) + LIST(APPEND _cxx_flags "-I${_f}") + LIST(APPEND _py_flags "-I${_f}") + ENDFOREACH() + + FOREACH(_input ${idlfiles}) + GET_FILENAME_COMPONENT(_base ${_input} NAME_WE) + GET_FILENAME_COMPONENT(_path ${_input} PATH) + IF(NOT _path) + SET(_input ${CMAKE_CURRENT_SOURCE_DIR}/${_input}) + ENDIF() + + SET(_inc ${CMAKE_CURRENT_BINARY_DIR}/${_base}.hh) + SET(_src ${CMAKE_CURRENT_BINARY_DIR}/${_base}SK.cc) + SET(_dynsrc ${CMAKE_CURRENT_BINARY_DIR}/${_base}DynSK.cc) + + LIST(APPEND _sources ${_src}) + LIST(APPEND _sources ${_dynsrc}) + SET(_outputs ${_inc} ${_src} ${_dynsrc}) + + ADD_CUSTOM_COMMAND(OUTPUT ${_outputs} + COMMAND ${OMNIORB_IDL_COMPILER} ${_cxx_flags} ${_input} + MAIN_DEPENDENCY ${_input}) + + INSTALL(FILES ${_input} DESTINATION idl/salome) + INSTALL(FILES ${_inc} DESTINATION include/salome) + IF(OMNIORB_PYTHON_BACKEND) - SET(IDLPYFLAGS "${IDLPYFLAGS} -p${OMNIORB_PYTHON_BACKEND}") - INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${IDLPYFLAGS}\" \"${input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )") - ENDIF(OMNIORB_PYTHON_BACKEND) - ENDFOREACH(input ${MYIDLFILES}) - ADD_LIBRARY(${MYMODULE} ${TYPE} ${MYSOURCES}) + STRING(REPLACE ";" " " _tmp "${_py_flags}") + INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${_tmp}\" \"${_input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )") + ENDIF() + ENDFOREACH() + + ADD_LIBRARY(${module} ${_type} ${_sources}) + TARGET_LINK_LIBRARIES(${module} ${_linklibs}) + SET_TARGET_PROPERTIES(${module} PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS}") ENDMACRO(OMNIORB_ADD_MODULE) -- 2.39.2