CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. # Update CTK_BASE_LIBRARIES with QT libraries
  94. IF(QT4_FOUND)
  95. SET(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK libraries" FORCE)
  96. ENDIF()
  97. #-----------------------------------------------------------------------------
  98. # CTK Libraries
  99. #
  100. SET(ctk_libs
  101. Core
  102. Widgets
  103. DICOM/Core
  104. DICOM/Widgets
  105. )
  106. #-----------------------------------------------------------------------------
  107. # CTK Plugins
  108. #
  109. SET(ctk_plugins
  110. org.commontk.cli
  111. )
  112. #-----------------------------------------------------------------------------
  113. # CTK Applications
  114. #
  115. SET(ctk_applications
  116. ctkDICOM
  117. ctkDICOMIndexer
  118. )
  119. #-----------------------------------------------------------------------------
  120. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  121. # before the SuperBuild script is included
  122. #
  123. # Let's mark as advanced some default properties
  124. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  125. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  126. # KWStyle
  127. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  128. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  129. # Build options associated with CTK libraries
  130. FOREACH(lib ${ctk_libs})
  131. OPTION(CTK_LIB_${lib} "Enable ${lib} Library." ON)
  132. ENDFOREACH()
  133. # Build options associated with CTK plugins
  134. FOREACH(plugin ${ctk_plugins})
  135. OPTION(CTK_PLUGIN_${plugin} "Build ${plugin} Plugin." ON)
  136. ENDFOREACH()
  137. # Build options associated with CTK applications
  138. FOREACH(app ${ctk_applications})
  139. OPTION(CTK_APP_${app} "Build ${app} Application." ON)
  140. ENDFOREACH()
  141. #-----------------------------------------------------------------------------
  142. # Superbuild is used by default
  143. #
  144. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  145. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  146. IF(CTK_SUPERBUILD)
  147. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  148. RETURN()
  149. ENDIF()
  150. #-----------------------------------------------------------------------------
  151. # Add CTK library subdirectories
  152. #
  153. FOREACH(lib ${ctk_libs})
  154. IF (CTK_LIB_${lib})
  155. ADD_SUBDIRECTORY(Libs/${lib})
  156. ENDIF()
  157. ENDFOREACH()
  158. #-----------------------------------------------------------------------------
  159. # Add CTK plugin subdirectories
  160. #
  161. FOREACH(plugin ${ctk_plugins})
  162. IF (CTK_PLUGIN_${plugin})
  163. ADD_SUBDIRECTORY(Plugins/${plugin})
  164. ENDIF()
  165. ENDFOREACH()
  166. #-----------------------------------------------------------------------------
  167. # Add CTK application subdirectories
  168. #
  169. FOREACH(app ${ctk_applications})
  170. IF (CTK_APP_${app})
  171. ADD_SUBDIRECTORY(Applications/${app})
  172. ENDIF()
  173. ENDFOREACH()
  174. #-----------------------------------------------------------------------------
  175. # Add general purpose subdirectories
  176. #
  177. ADD_SUBDIRECTORY(Testing)
  178. ADD_SUBDIRECTORY(Examples)
  179. #-----------------------------------------------------------------------------
  180. # Style Checking configuration
  181. #
  182. INCLUDE(Utilities/KWStyle/KWStyle.cmake)