CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
  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. #-----------------------------------------------------------------------------
  44. # Testing
  45. #
  46. OPTION(BUILD_TESTING "Test the project" ON)
  47. IF(BUILD_TESTING)
  48. ENABLE_TESTING()
  49. INCLUDE(CTest)
  50. SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
  51. MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
  52. # Setup file for setting custom ctest vars
  53. CONFIGURE_FILE(
  54. CMake/CTestCustom.cmake.in
  55. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  56. @ONLY
  57. )
  58. # Configuration for the CMake-generated test driver
  59. SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  60. SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  61. try
  62. {")
  63. SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  64. catch( std::exception & excp )
  65. {
  66. fprintf(stderr,\"%s\\n\",excp.what());
  67. return EXIT_FAILURE;
  68. }
  69. catch( ... )
  70. {
  71. printf(\"Exception caught in the test driver\\n\");
  72. return EXIT_FAILURE;
  73. }
  74. ")
  75. ENDIF()
  76. #-----------------------------------------------------------------------------
  77. # QT
  78. #
  79. ctkMacroSetupQt()
  80. #-----------------------------------------------------------------------------
  81. # CTK Libraries
  82. #
  83. SET(ctk_libs
  84. Core
  85. Widgets
  86. DICOM/Core
  87. DICOM/Widgets
  88. DICOM/Applications)
  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. # Let's mark as advanced some default properties
  94. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  95. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  96. # KWStyle
  97. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  98. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  99. # Build options
  100. FOREACH(lib ${ctk_libs})
  101. OPTION(CTK_ENABLE_${lib} "Enable ${lib} Support." ON)
  102. ENDFOREACH()
  103. #-----------------------------------------------------------------------------
  104. # Superbuild is used by default
  105. #
  106. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  107. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  108. IF(CTK_SUPERBUILD)
  109. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  110. RETURN()
  111. ENDIF()
  112. #-----------------------------------------------------------------------------
  113. # Add subdirectories
  114. #
  115. FOREACH(lib ${ctk_libs})
  116. IF (CTK_ENABLE_${lib})
  117. ADD_SUBDIRECTORY(Libs/${lib})
  118. ENDIF()
  119. ENDFOREACH()
  120. #-----------------------------------------------------------------------------
  121. # Style Checking configuration
  122. #
  123. INCLUDE(Utilities/KWStyle/KWStyle.cmake)