Просмотр исходного кода

ENH: CTK_EXTERNAL_LIBRARIES and (CTK_EXTERNAL_LIBRARY_DIRS are now exposed in CTKConfig.cmake

This will allow project building against CTK to link properly
with all the libraries associated with CTK external projects.
Jean-Christophe Fillion-Robin лет назад: 15
Родитель
Сommit
76ed761eb6

+ 4 - 0
CMakeExternals/DCMTK.cmake

@@ -32,5 +32,9 @@ IF(${add_project})
       ALWAYS 1
       ALWAYS 1
       WORKING_DIRECTORY ${ep_build_dir}/${proj}
       WORKING_DIRECTORY ${ep_build_dir}/${proj}
       )
       )
+      
+    # Since DCMTK is statically build, there is not need to add its corresponding 
+    # library output directory to CTK_EXTERNAL_LIBRARY_DIRS
+    
   ENDIF()
   ENDIF()
 ENDIF()
 ENDIF()

+ 3 - 0
CMakeExternals/KWStyle.cmake

@@ -21,5 +21,8 @@ IF(CTK_USE_KWSTYLE)
         ${ep_common_args}
         ${ep_common_args}
       )
       )
     SET(CTK_KWSTYLE_EXECUTABLE ${ep_install_dir}/bin/KWStyle)
     SET(CTK_KWSTYLE_EXECUTABLE ${ep_install_dir}/bin/KWStyle)
+    
+    # Since KWStyle is an executable, there is not need to add its corresponding 
+    # library output directory to CTK_EXTERNAL_LIBRARY_DIRS
   ENDIF()
   ENDIF()
 ENDIF()
 ENDIF()

+ 3 - 0
CMakeExternals/Log4Qt.cmake

@@ -24,6 +24,9 @@ IF(${add_project})
           -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
           -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
         )
         )
     SET(Log4Qt_DIR ${ep_install_dir})
     SET(Log4Qt_DIR ${ep_install_dir})
+    
+    # Since Log4Qt is statically build, there is not need to add its corresponding 
+    # library output directory to CTK_EXTERNAL_LIBRARY_DIRS
       
       
   ENDIF()
   ENDIF()
 ENDIF()
 ENDIF()

+ 4 - 0
CMakeExternals/PythonQt.cmake

@@ -33,5 +33,9 @@ IF(${add_project})
         -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
         -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
       )
       )
     SET(PYTHONQT_INSTALL_DIR ${ep_install_dir})
     SET(PYTHONQT_INSTALL_DIR ${ep_install_dir})
+    
+    # Since the full path of PythonQt library is used, there is not need to add 
+    # its corresponding library output directory to CTK_EXTERNAL_LIBRARY_DIRS
+    
   ENDIF()
   ENDIF()
 ENDIF()
 ENDIF()

+ 3 - 0
CMakeExternals/QtMobility.cmake

@@ -64,5 +64,8 @@ IF(${add_project})
     INSTALL_COMMAND ${qtmobility_install_cmd}
     INSTALL_COMMAND ${qtmobility_install_cmd}
     BUILD_IN_SOURCE 1
     BUILD_IN_SOURCE 1
     )
     )
+    
+  # Since the full path of QtMobility library is used, there is not need to add 
+  # its corresponding library output directory to CTK_EXTERNAL_LIBRARY_DIRS
 	
 	
 ENDIF()
 ENDIF()

+ 5 - 0
CMakeExternals/VTK.cmake

@@ -31,5 +31,10 @@ IF(${add_project})
         -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
         -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
       )
       )
     SET(VTK_DIR ${ep_build_dir}/${proj})
     SET(VTK_DIR ${ep_build_dir}/${proj})
+    
+    # Since the link directories associated with VTK is used, it makes sens to 
+    # update CTK_EXTERNAL_LIBRARY_DIRS with its associated library output directory
+    LIST(APPEND CTK_EXTERNAL_LIBRARY_DIRS ${VTK_DIR}/bin)
+  
   ENDIF()
   ENDIF()
 ENDIF()
 ENDIF()

+ 13 - 1
CTKConfig.cmake.in

@@ -48,8 +48,20 @@ SET(CTK_LIBRARIES @CTK_LIBRARIES@)
 # The CTK include file directories.
 # The CTK include file directories.
 SET(CTK_INCLUDE_DIRS "@CTK_INCLUDE_DIRS_CONFIG@")
 SET(CTK_INCLUDE_DIRS "@CTK_INCLUDE_DIRS_CONFIG@")
  
  
-# The CTK library directories.
+# The CTK library directories. Note that if
+# CTK_CONFIGURATION_TYPES is set (see below) then these directories
+# will be the parent directories under which there will be a directory
+# of runtime binaries for each configuration type.
 SET(CTK_LIBRARY_DIRS "@CTK_LIBRARY_DIRS_CONFIG@")
 SET(CTK_LIBRARY_DIRS "@CTK_LIBRARY_DIRS_CONFIG@")
+
+# The CTK external project libraries.
+SET(CTK_EXTERNAL_LIBRARIES "@CTK_EXTERNAL_LIBRARIES_CONFIG@")
+
+# The CTK external project library directories. Note that if
+# CTK_CONFIGURATION_TYPES is set (see below) then these directories
+# will be the parent directories under which there will be a directory
+# of runtime binaries for each configuration type.
+SET(CTK_EXTERNAL_LIBRARY_DIRS "@CTK_EXTERNAL_LIBRARY_DIRS_CONFIG@")
  
  
 # The CTK binary executable directories. Note that if
 # The CTK binary executable directories. Note that if
 # CTK_CONFIGURATION_TYPES is set (see below) then these directories
 # CTK_CONFIGURATION_TYPES is set (see below) then these directories

+ 9 - 0
SuperBuild.cmake

@@ -29,6 +29,14 @@
 #
 #
 
 
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
+# Declare CTK_EXTERNAL_LIBRARY_DIRS variable - This variable stores
+# the library output directory associated with the different external project
+# It's then used in Utilities/LastConfigureStep/CTKGenerateCTKConfig.cmake to 
+# configure CTKConfig.cmake.in
+# This variable would then be exposed to project building against CTK
+SET(CTK_EXTERNAL_LIBRARY_DIRS)
+
+#-----------------------------------------------------------------------------
 # Make sure ${CTK_BINARY_DIR}/CTK-build/bin exists
 # Make sure ${CTK_BINARY_DIR}/CTK-build/bin exists
 # May be used by some external project to install libs (e.g QtMobility)
 # May be used by some external project to install libs (e.g QtMobility)
 IF(NOT EXISTS ${CTK_BINARY_DIR}/CTK-build/bin)
 IF(NOT EXISTS ${CTK_BINARY_DIR}/CTK-build/bin)
@@ -207,6 +215,7 @@ ExternalProject_Add(${proj}
     -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
     -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
     -DCTK_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
     -DCTK_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
     -DCTK_C_FLAGS:STRING=${CTK_C_FLAGS}
     -DCTK_C_FLAGS:STRING=${CTK_C_FLAGS}
+    -DCTK_EXTERNAL_LIBRARY_DIRS:STRING=${CTK_EXTERNAL_LIBRARY_DIRS}
     -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
     -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
     -DCTKData_DIR:PATH=${CTKData_DIR}
     -DCTKData_DIR:PATH=${CTKData_DIR}
 	  -DZMQ_DIR:PATH=${ZMQ_DIR}                     # FindVTK expects VTK_DIR variable to be defined
 	  -DZMQ_DIR:PATH=${ZMQ_DIR}                     # FindVTK expects VTK_DIR variable to be defined

+ 36 - 0
Utilities/LastConfigureStep/CMakeLists.txt

@@ -43,6 +43,42 @@
 # end of CMakeLists processing, i.e. instead of waiting until some variables
 # end of CMakeLists processing, i.e. instead of waiting until some variables
 # are configured in SUBDIRS.
 # are configured in SUBDIRS.
 
 
+
+SET(ctk_target_dependencies)
+
+# Loop over the list of CTK* targets and retrieve the associated dependencies
+FOREACH(ctk_target ${CTEST_PROJECT_SUBPROJECTS})
+  LIST(APPEND ctk_target_dependencies ${${ctk_target}_LIB_DEPENDS})
+ENDFOREACH()
+
+
+SET(CTK_EXTERNAL_LIBRARIES)
+
+# Loop over dependencies and append to CTK_EXTERNAL_LIBRARIES 
+# target dependency which are neither CTK or static library
+SET(link_type)
+FOREACH(ctk_target_dependency ${ctk_target_dependencies})
+  STRING(REGEX MATCH "(general|optimized|debug)" is_link_type ${ctk_target_dependency})
+  IF(is_link_type)
+    SET(link_type ${ctk_target_dependency})
+  ELSE()
+    # Sanity checks - link_type shouldn't be empty
+    IF(link_type STREQUAL "")
+      MESSAGE(SEND_ERROR "link_type shouldn't be empty")
+    ENDIF()
+    # Make sure ctk_target_dependency is not a CTK library
+    STRING(REGEX MATCH "(^(c|C)(t|T)(k|K)[a-zA-Z0-9]+$)" is_ctk_library ${ctk_target_dependency})
+    IF(NOT is_ctk_library)
+      # Make sure ctk_target_dependency is not a static library
+      GET_FILENAME_COMPONENT(ctk_target_dependency_ext ${ctk_target_dependency} EXT)
+      IF(NOT ctk_target_dependency_ext STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
+        LIST(APPEND CTK_EXTERNAL_LIBRARIES ${link_type} ${ctk_target_dependency})
+      ENDIF()
+      SET(link_type)
+    ENDIF()
+  ENDIF()
+ENDFOREACH()
+
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
 # Create the CTKConfig.cmake file containing the CTK configuration.
 # Create the CTKConfig.cmake file containing the CTK configuration.
 # Since it might generate configuration file depending
 # Since it might generate configuration file depending

+ 13 - 7
Utilities/LastConfigureStep/CTKGenerateCTKConfig.cmake

@@ -64,9 +64,20 @@ SET(CTK_CONFIG_INSTALL_ONLY)
 # The "use" file.
 # The "use" file.
 SET(CTK_USE_FILE ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake)
 SET(CTK_USE_FILE ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake)
 
 
+# Determine the include directories needed.
+SET(CTK_INCLUDE_DIRS_CONFIG
+  ${CTK_BASE_INCLUDE_DIRS}
+)
+
 # Library directory.
 # Library directory.
 SET(CTK_LIBRARY_DIRS_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 SET(CTK_LIBRARY_DIRS_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 
 
+# External project libraries.
+SET(CTK_EXTERNAL_LIBRARIES_CONFIG ${CTK_EXTERNAL_LIBRARIES})
+
+# External project library directory.
+SET(CTK_EXTERNAL_LIBRARY_DIRS_CONFIG ${CTK_EXTERNAL_LIBRARY_DIRS})
+
 # Runtime library directory.
 # Runtime library directory.
 SET(CTK_RUNTIME_LIBRARY_DIRS_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 SET(CTK_RUNTIME_LIBRARY_DIRS_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
 
@@ -76,16 +87,11 @@ SET(CTK_EXECUTABLE_DIRS_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 # QtDesigner plugins directory
 # QtDesigner plugins directory
 SET(CTK_QTDESIGNERPLUGINS_DIR_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 SET(CTK_QTDESIGNERPLUGINS_DIR_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 
 
-# Determine the include directories needed.
-SET(CTK_INCLUDE_DIRS_CONFIG
-  ${CTK_BASE_INCLUDE_DIRS}
-)
-
 # Executable locations.
 # Executable locations.
 
 
 # CMake extension module directory.
 # CMake extension module directory.
-SET(CTK_CMAKE_DIR_CONFIG "${CTK_CMAKE_DIR}")
-SET(CTK_CMAKE_UTILITIES_DIR_CONFIG "${CTK_CMAKE_UTILITIES_DIR}")
+SET(CTK_CMAKE_DIR_CONFIG ${CTK_CMAKE_DIR})
+SET(CTK_CMAKE_UTILITIES_DIR_CONFIG ${CTK_CMAKE_UTILITIES_DIR})
 
 
 # Build configuration information.
 # Build configuration information.
 SET(CTK_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})
 SET(CTK_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})