CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
  21. #-----------------------------------------------------------------------------
  22. # Install directories, used for install rules.
  23. #
  24. SET(CTK_INSTALL_BIN_DIR "bin")
  25. SET(CTK_INSTALL_LIB_DIR "lib")
  26. SET(CTK_INSTALL_INCLUDE_DIR "include")
  27. SET(CTK_INSTALL_DOC_DIR "doc")
  28. #-----------------------------------------------------------------------------
  29. # Update CMake module path
  30. #
  31. SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
  32. #-----------------------------------------------------------------------------
  33. # Clear CTK_BASE_INCLUDE_DIRS and CTK_BASE_LIBRARIES
  34. #
  35. SET(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  36. SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  37. #-----------------------------------------------------------------------------
  38. # CMake Macro(s)
  39. #
  40. INCLUDE(CMake/CTKParseArgumentsMacro.cmake)
  41. INCLUDE(CMake/CTKBuildQtLibMacro.cmake)
  42. INCLUDE(CMake/CTKBuildQtPluginMacro.cmake)
  43. INCLUDE(CMake/CTKSetupQt.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 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  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. ctk_setup_qt()
  81. #-----------------------------------------------------------------------------
  82. # CTK Libraries
  83. #
  84. SET(ctk_libs
  85. Core
  86. Widgets
  87. DICOM/Core
  88. DICOM/Widgets)
  89. #-----------------------------------------------------------------------------
  90. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  91. # before the SuperBuild script is included
  92. #
  93. # KWStyle
  94. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  95. MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  96. # Build options
  97. FOREACH(lib ${ctk_libs})
  98. OPTION(CTK_USE_${lib} "Enable ${lib} Support." ON)
  99. ENDFOREACH()
  100. #-----------------------------------------------------------------------------
  101. # Superbuild is used by default
  102. #
  103. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  104. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  105. IF(CTK_SUPERBUILD)
  106. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  107. RETURN()
  108. ENDIF()
  109. #-----------------------------------------------------------------------------
  110. # Add subdirectories
  111. #
  112. FOREACH(lib ${ctk_libs})
  113. IF (CTK_USE_${lib})
  114. ADD_SUBDIRECTORY(Libs/${lib})
  115. ENDIF()
  116. ENDFOREACH()
  117. #-----------------------------------------------------------------------------
  118. # Style Checking configuration
  119. #
  120. INCLUDE(Utilities/KWStyle/KWStyle.cmake)