CMakeLists.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. project(CTKDICOMCore)
  2. #
  3. # See CTK/CMake/ctkMacroBuildLib.cmake for details
  4. #
  5. set(KIT_export_directive "CTK_DICOM_CORE_EXPORT")
  6. # determine the DCMTK version we're using
  7. if(EXISTS ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
  8. set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
  9. elseif(EXISTS ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
  10. set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
  11. else()
  12. message(SEND_ERROR "DCMTK version cannot be determined!")
  13. endif()
  14. file(READ ${_DCMTK_CONFIG_HEADER} _DCMTK_CONFIG)
  15. # simple check, we do not expect anything else
  16. if(_DCMTK_CONFIG MATCHES "PACKAGE_VERSION_NUMBER 360")
  17. set(DCMTK_VERSION_IS_360 1)
  18. message(STATUS "Detected DCMTK 3.6.0, will include backported SCU")
  19. endif()
  20. # Source files
  21. set(KIT_SRCS
  22. ctkDICOMAbstractThumbnailGenerator.cpp
  23. ctkDICOMAbstractThumbnailGenerator.h
  24. ctkDICOMDatabase.cpp
  25. ctkDICOMDatabase.h
  26. ctkDICOMItem.h
  27. ctkDICOMFilterProxyModel.cpp
  28. ctkDICOMFilterProxyModel.h
  29. ctkDICOMIndexer.cpp
  30. ctkDICOMIndexer.h
  31. ctkDICOMIndexer_p.h
  32. ctkDICOMItem.cpp
  33. ctkDICOMItem.h
  34. ctkDICOMModel.cpp
  35. ctkDICOMModel.h
  36. ctkDICOMObjectModel.cpp
  37. ctkDICOMObjectModel.h
  38. ctkDICOMPersonName.cpp
  39. ctkDICOMPersonName.h
  40. ctkDICOMQuery.cpp
  41. ctkDICOMQuery.h
  42. ctkDICOMRetrieve.cpp
  43. ctkDICOMRetrieve.h
  44. ctkDICOMTester.cpp
  45. ctkDICOMTester.h
  46. ctkDICOMUtil.cpp
  47. ctkDICOMUtil.h
  48. )
  49. if(DCMTK_VERSION_IS_360)
  50. list(APPEND KIT_SRCS ctkDcmSCU.cc)
  51. endif(DCMTK_VERSION_IS_360)
  52. # Abstract class should not be wrapped !
  53. set_source_files_properties(
  54. ctkDICOMAbstractThumbnailGenerator.h
  55. WRAP_EXCLUDE
  56. )
  57. # XXX DCMTK 3.6.1: Remove the HAVE_DCMTK_LOG4CPLUS_LOGGER test when DCMTK 3.6.1
  58. # can be expected on all supported platforms.
  59. # XXX On multi configuration system, there is no way to run 'try_compile` configure
  60. # tests based on the configuration that WILL be selected to build the project.
  61. # Since the try compile test 'HAVE_DCMTK_LOG4CPLUS_LOGGER' has originally been
  62. # added to be able to build against DCMTK 3.6.0 available by default on linux
  63. # distribution. Let's skip it in the case of multi configuration system and
  64. # assume DCMTK provides 'dcmtk::log4cplus::Logger'.
  65. # We also skip this test if DCMTK_CMAKE_DEBUG_POSTFIX is set, because then the
  66. # DCMTK_LIBRARIES variable will have a value similar to "debug <lib1> ..." which
  67. # will not link the DCMTK debug libraries in the try_compile call because
  68. # BUILD_TYPE cannot be set for the generated CMakeLists.txt file.
  69. # TODO When build as external project, the config of the parent project could be passed to CTK
  70. # and used as a hint. We need to define what would be the convention for such hint.
  71. if(DCMTK_CMAKE_DEBUG_POSTFIX OR (CMAKE_CONFIGURATION_TYPES AND NOT DEFINED HAVE_DCMTK_LOG4CPLUS_LOGGER))
  72. set(HAVE_DCMTK_LOG4CPLUS_LOGGER 1 CACHE INTERNAL "Test HAVE_DCMTK_LOG4CPLUS_LOGGER")
  73. endif()
  74. # Check if DCMTK provides 'dcmtk::log4cplus::Logger', if not fallback to 'log4cplus::Logger'.
  75. # Indeed, following DCMTK-3.6.1_20110519 (commit e39d190), log4cplus has been moved
  76. # into dcmtk::log4cplus namespace.
  77. include(CheckCXXSourceCompiles)
  78. set(CMAKE_REQUIRED_DEFINITIONS -DHAVE_CONFIG_H)
  79. set(CMAKE_REQUIRED_INCLUDES ${DCMTK_INCLUDE_DIRS})
  80. set(CMAKE_REQUIRED_LIBRARIES ${DCMTK_LIBRARIES})
  81. check_cxx_source_compiles(
  82. "#include <dcmtk/oflog/oflog.h>\nint main(int, char*[]){dcmtk::log4cplus::Logger logger; return 0;}"
  83. HAVE_DCMTK_LOG4CPLUS_LOGGER)
  84. if(HAVE_DCMTK_LOG4CPLUS_LOGGER)
  85. set_source_files_properties(
  86. ctkDICOMUtil.cpp
  87. PROPERTIES COMPILE_DEFINITIONS HAVE_DCMTK_LOG4CPLUS_LOGGER
  88. )
  89. endif()
  90. # Headers that should run through moc
  91. set(KIT_MOC_SRCS
  92. ctkDICOMAbstractThumbnailGenerator.h
  93. ctkDICOMDatabase.h
  94. ctkDICOMIndexer.h
  95. ctkDICOMIndexer_p.h
  96. ctkDICOMFilterProxyModel.h
  97. ctkDICOMModel.h
  98. ctkDICOMObjectModel.h
  99. ctkDICOMQuery.h
  100. ctkDICOMRetrieve.h
  101. ctkDICOMTester.h
  102. )
  103. # UI files
  104. set(KIT_UI_FORMS
  105. )
  106. # Resources
  107. set(KIT_resources
  108. Resources/ctkDICOMCore.qrc
  109. )
  110. # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
  111. # The following macro will read the target libraries from the file 'target_libraries.cmake'
  112. ctkFunctionGetTargetLibraries(KIT_target_libraries)
  113. if(CTK_QT_VERSION VERSION_GREATER "4")
  114. list(APPEND KIT_target_libraries Qt5::Sql Qt5::Gui)
  115. endif()
  116. # create a dcm query/retrieve service config file that points to the build dir
  117. set (DCMQRSCP_STORE_DIR ${CMAKE_CURRENT_BINARY_DIR}/Testing)
  118. configure_file( Resources/dcmqrscp.cfg.in dcmqrscp.cfg )
  119. set (DCMQRSCP_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/dcmqrscp.cfg)
  120. ctkMacroBuildLib(
  121. NAME ${PROJECT_NAME}
  122. EXPORT_DIRECTIVE ${KIT_export_directive}
  123. SRCS ${KIT_SRCS}
  124. MOC_SRCS ${KIT_MOC_SRCS}
  125. UI_FORMS ${KIT_UI_FORMS}
  126. TARGET_LIBRARIES ${KIT_target_libraries}
  127. RESOURCES ${KIT_resources}
  128. LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  129. )
  130. if(DEFINED DCMTK_HAVE_CONFIG_H_OPTIONAL AND NOT DCMTK_HAVE_CONFIG_H_OPTIONAL)
  131. # Workaround Debian packaging issue - See FindDCMTK.cmake for more details
  132. set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS ${DCMTK_DEFINITIONS})
  133. if("${CMAKE_VERSION}" VERSION_GREATER 2.8.10)
  134. set_target_properties(${PROJECT_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS ${DCMTK_DEFINITIONS})
  135. endif()
  136. endif()
  137. if(CTK_WRAP_PYTHONQT_LIGHT)
  138. ctkMacroBuildLibWrapper(
  139. TARGET ${PROJECT_NAME}
  140. SRCS ${KIT_SRCS}
  141. WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  142. )
  143. endif()
  144. # Plugins
  145. #if(CTK_BUILD_QTDESIGNER_PLUGINS)
  146. # add_subdirectory(Plugins)
  147. #endif()
  148. # Testing
  149. if(BUILD_TESTING)
  150. add_subdirectory(Testing)
  151. endif()