]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CMake: improved reloading of dependent CMake targets in Config file to
authorbruneton <bruneton>
Mon, 4 Nov 2013 09:01:13 +0000 (09:01 +0000)
committerbruneton <bruneton>
Mon, 4 Nov 2013 09:01:13 +0000 (09:01 +0000)
account for COMPONENTS.

CMakeLists.txt
SalomeKERNELConfig.cmake.in
salome_adm/cmake_files/SalomeMacros.cmake

index 52584fc152c27f5262a567e301fbcaae372f77a6..6288bb1f3111dd5e223b8fc091eb4e1edc1d7615 100755 (executable)
@@ -245,8 +245,13 @@ SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
 SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
 SET(SIMANIO_ROOT_DIR "${SIMANIO_ROOT_DIR}")
+
 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
+
+# Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
+SALOME_CONFIGURE_PREPARE(CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch 
+                         PThread Boost HDF5 libXml2 Python SIMANIO HDF5)
+
 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
index ac65b28b501a237d50b74e57ed47ccb81f80d8cd..2c5be26f82f615b12ecd5c66a8fc32e8c42d2f08 100644 (file)
@@ -105,21 +105,28 @@ SET_AND_CHECK(SWIG_ROOT_DIR_EXP     "@PACKAGE_SWIG_ROOT_DIR@")
 # For all prerequisites, load the corresponding targets if the package was used 
 # in CONFIG mode. This ensures dependent projects link correctly
 # without having to set LD_LIBRARY_PATH:
-SET(_PREREQ CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch PThread Boost HDF5 libXml2 Python SIMANIO)
-SET(_PREREQ_CONFIG_DIR "@CppUnit_DIR@" "@Graphviz_DIR@" "@Doxygen_DIR@" "@Sphinx_DIR@" 
-      "@MPI_DIR@" "@omniORB_DIR@" "@LibBatch_DIR@" "@PThread_DIR@" "@Boost_DIR@" "@HDF5_DIR@"
-      "@libXml2_DIR@" "@Python_DIR@" "@SIMANIO_DIR@")
+SET(_PREREQ @_PREREQ_LIST@)
+SET(_PREREQ_CONFIG_DIR @_PREREQ_DIR_LIST@)
+SET(_PREREQ_COMPONENTS "@_PREREQ_COMPO_LIST@")
 LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
 # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
 MATH(EXPR _range "${_list_len}-1")
 FOREACH(_p RANGE ${_range})  
   LIST(GET _PREREQ            ${_p} _pkg    )
   LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir)
-  IF(_pkg_dir)
-     MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
-     FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE 
+  LIST(GET _PREREQ_COMPONENTS ${_p} _pkg_compo)
+  MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
+  IF(NOT _pkg_compo)
+    FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE 
           PATHS "${_pkg_dir}" 
           NO_DEFAULT_PATH)
+  ELSE()
+    STRING(REPLACE "," ";" _compo_lst "${_pkg_compo}")
+    MESSAGE(STATUS "===> (components: ${_pkg_compo})")
+    FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
+          COMPONENTS ${_compo_lst} 
+          PATHS "${_pkg_dir}"
+          NO_DEFAULT_PATH)
   ENDIF()
 ENDFOREACH()
 
index 38e29a2104f0bec8d141f019ddc96c939be51faf..8dac560f026a9f7262f131c8e16cb152e35de2da 100755 (executable)
@@ -778,7 +778,7 @@ ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
 MACRO(SALOME_APPEND_LIST_OF_LIST result element_list)
   SET(_tmp_res)
   STRING(REPLACE ";" "," _tmp_res "${${element_list}}")
-  LIST(APPEND ${result} ${_tmp_res})
+  SET(${result} "${${result}};${_tmp_res}")  # LIST(APPEND ...) doesn't handle well empty elements!?
 ENDMACRO(SALOME_APPEND_LIST_OF_LIST)
 
 #########################################################################
@@ -808,4 +808,4 @@ MACRO(SALOME_CONFIGURE_PREPARE)
       SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS)
     ENDIF()
   ENDFOREACH()
-ENDMACRO(SALOME_CONFIGURE_PREPARE)
\ No newline at end of file
+ENDMACRO(SALOME_CONFIGURE_PREPARE)