]> SALOME platform Git repositories - plugins/hexablockplugin.git/commitdiff
Salome HOME
CMake: improved reloading of dependent CMake targets in Config file to
authormpa <mpa@opencascade.com>
Tue, 5 Nov 2013 12:44:47 +0000 (12:44 +0000)
committermpa <mpa@opencascade.com>
Tue, 5 Nov 2013 12:44:47 +0000 (12:44 +0000)
account for COMPONENTS.

CMakeLists.txt
SalomeHEXABLOCKPLUGINConfig.cmake.in

index a958dc8573a2662f7847bb04569591e7b388abe2..0b882ba93181ba4d846fe66d1ae6efcb1ca94aaa 100755 (executable)
@@ -226,6 +226,10 @@ EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
  
 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
 SET(SMESH_ROOT_DIR "${SMESH_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() #For use in the future
+
 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
index 718e5d3196714de07b4d748664cc4e40b925d776..1aa1ce4aba710d936b536657500e6742044d2f70 100644 (file)
@@ -65,21 +65,32 @@ SET_AND_CHECK(HEXABLOCK_ROOT_DIR_EXP "@PACKAGE_HEXABLOCK_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:
 # 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 )
-SET(_PREREQ_CONFIG_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)
 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 
+IF(NOT _list_len EQUAL 0)
+  # 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)
+    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)
           PATHS "${_pkg_dir}"
           NO_DEFAULT_PATH)
-  ENDIF()
-ENDFOREACH()
+    ENDIF()
+  ENDFOREACH()
+ENDIF()
 
 # Installation directories
 SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@")
 
 # Installation directories
 SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@")