]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
CMake build procedure improvements:
authorvsr <vsr@opencascade.com>
Tue, 20 Aug 2013 10:01:40 +0000 (10:01 +0000)
committervsr <vsr@opencascade.com>
Tue, 20 Aug 2013 10:01:40 +0000 (10:01 +0000)
- CORBA staff

idl/CMakeLists.txt
salome_adm/cmake_files/FindOmniORB.cmake
salome_adm/cmake_files/FindOmniORBPy.cmake
salome_adm/cmake_files/UseOmniORB.cmake

index 3ca0b8e8745fcac90079b4e63cf7c9a60c7bf1f0..3cb948304f9fea370fc05906beb6735caf525412 100755 (executable)
@@ -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})
 
index 11504fa0991df9f2b8fd832623a366caabae2cc3..397b4b6c0feb30763c707cce95e55421f6df5d3c 100644 (file)
@@ -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)
index a151c54a9b7058994413d1bcfd91c457590f36b9..5484e2e4c7b9ca2fff30e4cf540f028812602b32 100644 (file)
@@ -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})
 
index 1efa8b206219ad58a6e18e4eed1c88c0e4e47f34..7d63d22f26c85bf767487d7003e3d94dfc66202e 100644 (file)
@@ -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)