Browse Source

Support CMAKE_DEBUG_POSTFIX for CTK superbuild and external DCMTK.

Sascha Zelzer 10 years ago
parent
commit
635b060d98

+ 3 - 0
CMake/CTKConfig.cmake.in

@@ -31,6 +31,9 @@ set_and_check(CTK_EXPORT_HEADER_TEMPLATE "@PACKAGE_CTK_EXPORT_HEADER_TEMPLATE_DI
 set_and_check(CTK_LIBRARY_DIR "@PACKAGE_CTK_LIBRARY_DIR_CONFIG@")
 set(CTK_LIBRARY_DIRS ${CTK_LIBRARY_DIR})
 
+# CTK specific variables
+set(CTK_CMAKE_DEBUG_POSTFIX "@CMAKE_DEBUG_POSTFIX@")
+
 # Import CTK targets
 if(NOT TARGET CTKCore)
   include(${CTK_TARGETS})

+ 7 - 0
CMakeExternals/DCMTK.cmake

@@ -83,3 +83,10 @@ mark_as_superbuild(
   LABELS "FIND_PACKAGE"
   )
 
+# If an external DCMTK was provided via DCMTK_DIR and the external DCMTK
+# build/install used a CMAKE_DEBUG_POSTFIX value for distinguishing debug
+# and release libraries in the same build/install tree, the same debug
+# postfix needs to be passed to the CTK configure step. The FindDCMTK
+# script then takes the DCMTK_CMAKE_DEBUG_POSTFIX variable into account
+# when looking for DCMTK debug libraries.
+mark_as_superbuild(DCMTK_CMAKE_DEBUG_POSTFIX:STRING)

+ 6 - 1
CMakeLists.txt

@@ -79,7 +79,12 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
   mark_as_superbuild(VARS CMAKE_BUILD_TYPE ALL_PROJECTS)
 endif()
 
-mark_as_superbuild(CMAKE_PREFIX_PATH)
+mark_as_superbuild(
+  VARS
+    CMAKE_PREFIX_PATH:STRING
+    CMAKE_DEBUG_POSTFIX:STRING
+  ALL_PROJECTS
+  )
 
 #-----------------------------------------------------------------------------
 # Superbuild Option - Enabled by default

+ 5 - 1
Libs/DICOM/Core/CMakeLists.txt

@@ -71,9 +71,13 @@ set_source_files_properties(
 #     added to be able to build against DCMTK 3.6.0 available by default on linux
 #     distribution. Let's skip it in the case of multi configuration system and
 #     assume DCMTK provides 'dcmtk::log4cplus::Logger'.
+#     We also skip this test if DCMTK_CMAKE_DEBUG_POSTFIX is set, because then the
+#     DCMTK_LIBRARIES variable will have a value similar to "debug <lib1> ..." which
+#     will not link the DCMTK debug libraries in the try_compile call because
+#     BUILD_TYPE cannot be set for the generated CMakeLists.txt file.
 # TODO When build as external project, the config of the parent project could be passed to CTK
 #      and used as a hint. We need to define what would be the convention for such hint.
-if(CMAKE_CONFIGURATION_TYPES AND NOT DEFINED HAVE_DCMTK_LOG4CPLUS_LOGGER)
+if(DCMTK_CMAKE_DEBUG_POSTFIX OR (CMAKE_CONFIGURATION_TYPES AND NOT DEFINED HAVE_DCMTK_LOG4CPLUS_LOGGER))
   set(HAVE_DCMTK_LOG4CPLUS_LOGGER 1 CACHE INTERNAL "Test HAVE_DCMTK_LOG4CPLUS_LOGGER")
 endif()
 # Check if DCMTK provides 'dcmtk::log4cplus::Logger', if not fallback to 'log4cplus::Logger'.

+ 1 - 1
Utilities/CMake/FindDCMTK.cmake

@@ -191,7 +191,7 @@ foreach(lib
 
   # Find Debug libraries
   find_library(DCMTK_${lib}_LIBRARY_DEBUG
-    ${lib}
+    ${lib}${DCMTK_CMAKE_DEBUG_POSTFIX}
     PATHS
     ${DCMTK_DIR}/${lib}/libsrc
     ${DCMTK_DIR}/${lib}/libsrc/Debug

+ 11 - 2
Utilities/CMake/FindPythonQt.cmake

@@ -11,11 +11,20 @@ endif()
 
 find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
 find_path(PYTHONQT_INCLUDE_DIR PythonQt.h "${PYTHONQT_INSTALL_DIR}/include/PythonQt" DOC "Path to the PythonQt include directory")
-find_library(PYTHONQT_LIBRARY PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
+find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
+find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt${CTK_CMAKE_DEBUG_POSTFIX} PythonQt${CMAKE_DEBUG_POSTFIX} PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
+set(PYTHONQT_LIBRARY)
+if(PYTHONQT_LIBRARY_RELEASE)
+  list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
+endif()
+if(PYTHONQT_LIBRARY_DEBUG)
+  list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
+endif()
 
 mark_as_advanced(PYTHONQT_INSTALL_DIR)
 mark_as_advanced(PYTHONQT_INCLUDE_DIR)
-mark_as_advanced(PYTHONQT_LIBRARY)
+mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
+mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
 
 # On linux, also find libutil
 if(UNIX AND NOT APPLE)