CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  92. # before the SuperBuild script is included
  93. #
  94. # Let's mark as advanced some default properties
  95. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  96. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  97. # KWStyle
  98. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  99. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  100. # Build options
  101. FOREACH(lib ${ctk_libs})
  102. OPTION(CTK_ENABLE_${lib} "Enable ${lib} Support." ON)
  103. ENDFOREACH()
  104. #-----------------------------------------------------------------------------
  105. # Superbuild is used by default
  106. #
  107. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  108. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  109. IF(CTK_SUPERBUILD)
  110. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  111. RETURN()
  112. ENDIF()
  113. #-----------------------------------------------------------------------------
  114. # Add subdirectories
  115. #
  116. FOREACH(lib ${ctk_libs})
  117. IF (CTK_ENABLE_${lib})
  118. ADD_SUBDIRECTORY(Libs/${lib})
  119. ENDIF()
  120. ENDFOREACH()
  121. #-----------------------------------------------------------------------------
  122. # Style Checking configuration
  123. #
  124. INCLUDE(Utilities/KWStyle/KWStyle.cmake)