CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. DICOM/Applications)
  90. #-----------------------------------------------------------------------------
  91. # CTK Plugins
  92. #
  93. SET(ctk_plugins
  94. org.commontk.cli
  95. )
  96. #-----------------------------------------------------------------------------
  97. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  98. # before the SuperBuild script is included
  99. #
  100. # Let's mark as advanced some default properties
  101. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  102. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  103. # KWStyle
  104. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  105. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  106. # Build options associated with CTK libraries
  107. FOREACH(lib ${ctk_libs})
  108. OPTION(CTK_ENABLE_${lib} "Enable ${lib} Support." ON)
  109. ENDFOREACH()
  110. # Build options associated with CTK plugins
  111. FOREACH(plugin ${ctk_plugins})
  112. OPTION(CTK_ENABLE_${plugin} "Enable ${plugin} Support." ON)
  113. ENDFOREACH()
  114. #-----------------------------------------------------------------------------
  115. # Superbuild is used by default
  116. #
  117. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  118. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  119. IF(CTK_SUPERBUILD)
  120. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  121. RETURN()
  122. ENDIF()
  123. #-----------------------------------------------------------------------------
  124. # Add CTK libraries subdirectories
  125. #
  126. FOREACH(lib ${ctk_libs})
  127. IF (CTK_ENABLE_${lib})
  128. ADD_SUBDIRECTORY(Libs/${lib})
  129. ENDIF()
  130. ENDFOREACH()
  131. #-----------------------------------------------------------------------------
  132. # Add CTK plugins subdirectories
  133. #
  134. FOREACH(plugin ${ctk_plugins})
  135. IF (CTK_ENABLE_${plugin})
  136. ADD_SUBDIRECTORY(Plugins/${plugin})
  137. ENDIF()
  138. ENDFOREACH()
  139. #-----------------------------------------------------------------------------
  140. # Add general purpose subdirectories
  141. #
  142. ADD_SUBDIRECTORY(Applications)
  143. ADD_SUBDIRECTORY(Testing)
  144. ADD_SUBDIRECTORY(Examples)
  145. #-----------------------------------------------------------------------------
  146. # Style Checking configuration
  147. #
  148. INCLUDE(Utilities/KWStyle/KWStyle.cmake)