浏览代码

Associate DCMTK_DEFINITIONS to CTKDICOMCore

Following commit 12c052ff1, FindDCMTK.cmake has been updated to
detect if HAVE_CONFIG_H should be passed when compiling against
older version of DCMTK packaged on Debian.

To keep build system of project depending on CTK simple, instead of
manually adding the definition for all target depending
on CTKDCMTKCore, the definition is added as a target
property INTERFACE_COMPILE_DEFINITIONS to CTKDCMTKCore in CTKConfig.cmake.

That way, all target depending on the imported target CTKDCMTKCore
will automatically specify the -DHAVE_CONFIG_H flag.

Since the property INTERFACE_COMPILE_DEFINITIONS has been added
in CMake 2.8.11, it will still be required to specify the definition
manually in project using older version of CMake.

See #413
Jean-Christophe Fillion-Robin 11 年之前
父节点
当前提交
a32f524275
共有 2 个文件被更改,包括 15 次插入2 次删除
  1. 2 2
      CMake/CTKConfig.cmake.in
  2. 13 0
      CMake/LastConfigureStep/CTKGenerateCTKConfig.cmake

+ 2 - 2
CMake/CTKConfig.cmake.in

@@ -31,13 +31,13 @@ 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_CONFIG_CODE@
-
 # Import CTK targets
 if(NOT TARGET CTKCore)
   include(${CTK_TARGETS})
 endif()
 
+@CTK_CONFIG_CODE@
+
 # Include CTK macros
 include("${CTK_CMAKE_DIR}/ctkFunctionGetGccVersion.cmake")
 include("${CTK_CMAKE_DIR}/ctkFunctionCheckCompilerFlags.cmake")

+ 13 - 0
CMake/LastConfigureStep/CTKGenerateCTKConfig.cmake

@@ -162,6 +162,12 @@ set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# External project libraries\n")
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}set(CTK_EXTERNAL_LIBRARIES \"${CTK_EXTERNAL_LIBRARIES}\")\n")
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# External project library directories\n")
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}set(CTK_EXTERNAL_LIBRARY_DIRS \"${CTK_EXTERNAL_LIBRARY_DIRS}\")\n")
+if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL AND TARGET CTKDICOMCore)
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# Definition required to build DCMTK dependent libraries\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}if(\"\${CMAKE_VERSION}\" VERSION_GREATER 2.8.10)\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}  set_target_properties(CTKDICOMCore PROPERTIES INTERFACE_COMPILE_DEFINITIONS ${DCMTK_DEFINITIONS})\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}endif()\n")
+endif()
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}##################################################")
 
 set(ctk_config ${CTK_SUPERBUILD_BINARY_DIR}/CTKConfig.cmake)
@@ -200,6 +206,13 @@ set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# CTK library directories that could be u
 foreach(lib ${CTK_LIBRARIES})
   set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}set(${lib}_LIBRARY_DIRS \"\")\n")
 endforeach()
+if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL AND TARGET CTKDICOMCore)
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# Definition required to build DCMTK dependent libraries\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}if(\"\${CMAKE_VERSION}\" VERSION_GREATER 2.8.10)\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}  set_target_properties(CTKDICOMCore PROPERTIES INTERFACE_COMPILE_DEFINITIONS ${DCMTK_DEFINITIONS})\n")
+  set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}endif()\n")
+endif()
+
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}##################################################")
 
 set(ctk_install_config ${CMAKE_BINARY_DIR}/CMakeFiles/CTKConfig.cmake)