CMakeLists.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
  2. IF(COMMAND CMAKE_POLICY)
  3. CMAKE_POLICY(SET CMP0003 NEW)
  4. ENDIF(COMMAND CMAKE_POLICY)
  5. PROJECT(CTK)
  6. # Default to shared library
  7. SET(CTK_LIBRARY_MODE "SHARED")
  8. SET(CTK_BUILD_SHARED_LIBS TRUE)
  9. #-----------------------------------------------------------------------------
  10. # Output directories.
  11. #
  12. IF(NOT LIBRARY_OUTPUT_PATH)
  13. SET(LIBRARY_OUTPUT_PATH ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
  14. ENDIF(NOT LIBRARY_OUTPUT_PATH)
  15. IF(NOT EXECUTABLE_OUTPUT_PATH)
  16. SET(EXECUTABLE_OUTPUT_PATH ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
  17. ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
  18. SET(CTK_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
  19. SET(CTK_EXECUTABLE_PATH ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
  20. #-----------------------------------------------------------------------------
  21. # Install directories, used for install rules.
  22. #
  23. SET(CTK_INSTALL_BIN_DIR "bin")
  24. SET(CTK_INSTALL_LIB_DIR "lib")
  25. SET(CTK_INSTALL_INCLUDE_DIR "include")
  26. SET(CTK_INSTALL_DOC_DIR "doc")
  27. #-----------------------------------------------------------------------------
  28. # Update CMake module path
  29. # Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
  30. #
  31. SET(CMAKE_MODULE_PATH
  32. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
  33. "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  34. ${CMAKE_MODULE_PATH})
  35. #-----------------------------------------------------------------------------
  36. # Clear CTK_BASE_INCLUDE_DIRS and CTK_BASE_LIBRARIES
  37. #
  38. SET(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  39. SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  40. #-----------------------------------------------------------------------------
  41. # CMake Macro(s)
  42. #
  43. INCLUDE(CMake/ctkMacroParseArguments.cmake)
  44. INCLUDE(CMake/ctkMacroBuildQtLib.cmake)
  45. INCLUDE(CMake/ctkMacroBuildQtPlugin.cmake)
  46. INCLUDE(CMake/ctkMacroBuildQtApp.cmake)
  47. INCLUDE(CMake/ctkMacroSetupQt.cmake)
  48. INCLUDE(CMake/ctkMacroGetTargetLibraries.cmake)
  49. #-----------------------------------------------------------------------------
  50. # Patch program
  51. #
  52. FIND_PROGRAM(CTK_PATCH_EXECUTABLE patch
  53. "C:/Program Files/GnuWin32/bin"
  54. "C:/Program Files (x86)/GnuWin32/bin")
  55. MARK_AS_ADVANCED(CTK_PATCH_EXECUTABLE)
  56. #-----------------------------------------------------------------------------
  57. # Testing
  58. #
  59. OPTION(BUILD_TESTING "Test the project" ON)
  60. IF(BUILD_TESTING)
  61. ENABLE_TESTING()
  62. INCLUDE(CTest)
  63. SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
  64. MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
  65. # Setup file for setting custom ctest vars
  66. CONFIGURE_FILE(
  67. CMake/CTestCustom.cmake.in
  68. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  69. @ONLY
  70. )
  71. # Configuration for the CMake-generated test driver
  72. SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  73. SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  74. try
  75. {")
  76. SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  77. catch( std::exception & excp )
  78. {
  79. fprintf(stderr,\"%s\\n\",excp.what());
  80. return EXIT_FAILURE;
  81. }
  82. catch( ... )
  83. {
  84. printf(\"Exception caught in the test driver\\n\");
  85. return EXIT_FAILURE;
  86. }
  87. ")
  88. ENDIF()
  89. #-----------------------------------------------------------------------------
  90. # QT
  91. #
  92. ctkMacroSetupQt()
  93. #-----------------------------------------------------------------------------
  94. # CTK Libraries
  95. #
  96. SET(ctk_libs
  97. Core
  98. Widgets
  99. DICOM/Core
  100. DICOM/Widgets
  101. )
  102. #-----------------------------------------------------------------------------
  103. # CTK Plugins
  104. #
  105. SET(ctk_plugins
  106. org.commontk.cli
  107. )
  108. #-----------------------------------------------------------------------------
  109. # CTK Applications
  110. #
  111. SET(ctk_applications
  112. ctkDICOM
  113. ctkDICOMIndexer
  114. )
  115. #-----------------------------------------------------------------------------
  116. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  117. # before the SuperBuild script is included
  118. #
  119. # Let's mark as advanced some default properties
  120. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  121. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  122. # KWStyle
  123. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  124. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  125. # Build options associated with CTK libraries
  126. FOREACH(lib ${ctk_libs})
  127. OPTION(CTK_LIB_${lib} "Enable ${lib} Library." ON)
  128. ENDFOREACH()
  129. # Build options associated with CTK plugins
  130. FOREACH(plugin ${ctk_plugins})
  131. OPTION(CTK_PLUGIN_${plugin} "Build ${plugin} Plugin." ON)
  132. ENDFOREACH()
  133. # Build options associated with CTK applications
  134. FOREACH(app ${ctk_applications})
  135. OPTION(CTK_APP_${app} "Build ${app} Application." ON)
  136. ENDFOREACH()
  137. #-----------------------------------------------------------------------------
  138. # Superbuild is used by default
  139. #
  140. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  141. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  142. IF(CTK_SUPERBUILD)
  143. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  144. RETURN()
  145. ENDIF()
  146. #-----------------------------------------------------------------------------
  147. # Add CTK library subdirectories
  148. #
  149. FOREACH(lib ${ctk_libs})
  150. IF (CTK_LIB_${lib})
  151. ADD_SUBDIRECTORY(Libs/${lib})
  152. ENDIF()
  153. ENDFOREACH()
  154. #-----------------------------------------------------------------------------
  155. # Add CTK plugin subdirectories
  156. #
  157. FOREACH(plugin ${ctk_plugins})
  158. IF (CTK_PLUGIN_${plugin})
  159. ADD_SUBDIRECTORY(Plugins/${plugin})
  160. ENDIF()
  161. ENDFOREACH()
  162. #-----------------------------------------------------------------------------
  163. # Add CTK application subdirectories
  164. #
  165. FOREACH(app ${ctk_applications})
  166. IF (CTK_APP_${app})
  167. ADD_SUBDIRECTORY(Applications/${app})
  168. ENDIF()
  169. ENDFOREACH()
  170. #-----------------------------------------------------------------------------
  171. # Add general purpose subdirectories
  172. #
  173. ADD_SUBDIRECTORY(Testing)
  174. ADD_SUBDIRECTORY(Examples)
  175. #-----------------------------------------------------------------------------
  176. # Style Checking configuration
  177. #
  178. INCLUDE(Utilities/KWStyle/KWStyle.cmake)