CMakeLists.txt 5.5 KB

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