CMakeLists.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. # Testing
  51. #
  52. OPTION(BUILD_TESTING "Test the project" ON)
  53. IF(BUILD_TESTING)
  54. ENABLE_TESTING()
  55. INCLUDE(CTest)
  56. SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
  57. MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
  58. # Setup file for setting custom ctest vars
  59. CONFIGURE_FILE(
  60. CMake/CTestCustom.cmake.in
  61. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  62. @ONLY
  63. )
  64. # Configuration for the CMake-generated test driver
  65. SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  66. SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  67. try
  68. {")
  69. SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  70. catch( std::exception & excp )
  71. {
  72. fprintf(stderr,\"%s\\n\",excp.what());
  73. return EXIT_FAILURE;
  74. }
  75. catch( ... )
  76. {
  77. printf(\"Exception caught in the test driver\\n\");
  78. return EXIT_FAILURE;
  79. }
  80. ")
  81. ENDIF()
  82. #-----------------------------------------------------------------------------
  83. # QT
  84. #
  85. ctkMacroSetupQt()
  86. #-----------------------------------------------------------------------------
  87. # CTK Libraries
  88. #
  89. SET(ctk_libs
  90. Core
  91. Widgets
  92. DICOM/Core
  93. DICOM/Widgets
  94. )
  95. #-----------------------------------------------------------------------------
  96. # CTK Plugins
  97. #
  98. SET(ctk_plugins
  99. org.commontk.cli
  100. )
  101. #-----------------------------------------------------------------------------
  102. # CTK Applications
  103. #
  104. SET(ctk_applications
  105. ctkDICOM
  106. #ctkDICOMIndexer
  107. )
  108. #-----------------------------------------------------------------------------
  109. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  110. # before the SuperBuild script is included
  111. #
  112. # Let's mark as advanced some default properties
  113. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  114. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  115. # KWStyle
  116. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  117. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  118. # Build options associated with CTK libraries
  119. FOREACH(lib ${ctk_libs})
  120. OPTION(CTK_LIB_${lib} "Enable ${lib} Library." ON)
  121. ENDFOREACH()
  122. # Build options associated with CTK plugins
  123. FOREACH(plugin ${ctk_plugins})
  124. OPTION(CTK_PLUGIN_${plugin} "Build ${plugin} Plugin." ON)
  125. ENDFOREACH()
  126. # Build options associated with CTK applications
  127. FOREACH(app ${ctk_applications})
  128. OPTION(CTK_APP_${app} "Build ${app} Application." ON)
  129. ENDFOREACH()
  130. #-----------------------------------------------------------------------------
  131. # Superbuild is used by default
  132. #
  133. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  134. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  135. IF(CTK_SUPERBUILD)
  136. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  137. RETURN()
  138. ENDIF()
  139. #-----------------------------------------------------------------------------
  140. # Add CTK library subdirectories
  141. #
  142. FOREACH(lib ${ctk_libs})
  143. IF (CTK_LIB_${lib})
  144. ADD_SUBDIRECTORY(Libs/${lib})
  145. ENDIF()
  146. ENDFOREACH()
  147. #-----------------------------------------------------------------------------
  148. # Add CTK plugin subdirectories
  149. #
  150. FOREACH(plugin ${ctk_plugins})
  151. IF (CTK_PLUGIN_${plugin})
  152. ADD_SUBDIRECTORY(Plugins/${plugin})
  153. ENDIF()
  154. ENDFOREACH()
  155. #-----------------------------------------------------------------------------
  156. # Add CTK application subdirectories
  157. #
  158. FOREACH(app ${ctk_applications})
  159. IF (CTK_APP_${app})
  160. ADD_SUBDIRECTORY(Applications/${app})
  161. ENDIF()
  162. ENDFOREACH()
  163. #-----------------------------------------------------------------------------
  164. # Add general purpose subdirectories
  165. #
  166. ADD_SUBDIRECTORY(Testing)
  167. ADD_SUBDIRECTORY(Examples)
  168. #-----------------------------------------------------------------------------
  169. # Style Checking configuration
  170. #
  171. INCLUDE(Utilities/KWStyle/KWStyle.cmake)