CMakeLists.txt 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) Kitware Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0.txt
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. ###########################################################################
  20. cmake_minimum_required(VERSION 2.8.4)
  21. #-----------------------------------------------------------------------------
  22. # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
  23. #
  24. set(project_policies
  25. CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
  26. CMP0002 # NEW: Logical target names must be globally unique.
  27. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
  28. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
  29. CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
  30. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
  31. CMP0007 # NEW: List command no longer ignores empty elements.
  32. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
  33. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
  34. CMP0010 # NEW: Bad variable reference syntax is an error.
  35. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
  36. CMP0012 # NEW: if() recognizes numbers and boolean constants.
  37. CMP0013 # NEW: Duplicate binary directories are not allowed.
  38. CMP0014 # NEW: Input directories must have CMakeLists.txt
  39. )
  40. foreach(policy ${project_policies})
  41. if(POLICY ${policy})
  42. cmake_policy(SET ${policy} NEW)
  43. endif()
  44. endforeach()
  45. #-----------------------------------------------------------------------------
  46. if(APPLE)
  47. # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
  48. # we ensure that the bitness will be properly detected.
  49. include(${CMAKE_SOURCE_DIR}/CMake/ctkBlockSetCMakeOSXVariables.cmake)
  50. endif()
  51. #-----------------------------------------------------------------------------
  52. project(CTK)
  53. #-----------------------------------------------------------------------------
  54. #-----------------------------------------------------------------------------
  55. # Library mode: SHARED (default) or STATIC
  56. #
  57. set(CTK_LIBRARY_MODE "SHARED")
  58. option(CTK_BUILD_SHARED_LIBS "Build CTK libraries as shared module." ON)
  59. mark_as_advanced(CTK_BUILD_SHARED_LIBS)
  60. if(NOT CTK_BUILD_SHARED_LIBS)
  61. set(CTK_LIBRARY_MODE "STATIC")
  62. endif()
  63. #-----------------------------------------------------------------------------
  64. # Set a default build type if none was specified
  65. #
  66. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  67. message(STATUS "Setting build type to 'Debug' as none was specified.")
  68. set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  69. mark_as_advanced(CMAKE_BUILD_TYPE)
  70. # Set the possible values of build type for cmake-gui
  71. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
  72. "MinSizeRel" "RelWithDebInfo")
  73. endif()
  74. #-----------------------------------------------------------------------------
  75. # Superbuild Option - Enabled by default
  76. #
  77. option(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  78. mark_as_advanced(CTK_SUPERBUILD)
  79. #-----------------------------------------------------------------------------
  80. # Output directories.
  81. #
  82. foreach(type LIBRARY RUNTIME ARCHIVE)
  83. # Make sure the directory exists
  84. if(DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY
  85. AND NOT EXISTS ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  86. message(FATAL_ERROR "CTK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${CTK_CMAKE_${type}_OUTPUT_DIRECTORY}]")
  87. endif()
  88. if(CTK_SUPERBUILD)
  89. set(output_dir ${CTK_BINARY_DIR}/bin)
  90. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  91. set(CTK_CMAKE_${type}_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
  92. endif()
  93. else()
  94. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  95. set(output_dir ${CTK_BINARY_DIR}/bin)
  96. else()
  97. set(output_dir ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  98. endif()
  99. endif()
  100. set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
  101. if(NOT DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY)
  102. set(CTK_PLUGIN_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
  103. endif()
  104. endforeach()
  105. #-----------------------------------------------------------------------------
  106. # CTK version number. An even minor number corresponds to releases.
  107. #
  108. set(CTK_MAJOR_VERSION 0)
  109. set(CTK_MINOR_VERSION 1)
  110. set(CTK_PATCH_VERSION 0)
  111. set(CTK_VERSION
  112. "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_PATCH_VERSION}")
  113. # Append the library version information to the library target
  114. # properties. A parent project may set its own properties and/or may
  115. # block this.
  116. if(NOT CTK_NO_LIBRARY_VERSION)
  117. set(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
  118. VERSION "${CTK_VERSION}"
  119. SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
  120. )
  121. endif()
  122. #-----------------------------------------------------------------------------
  123. # Install directories, used for install rules.
  124. #
  125. if(NOT CTK_INSTALL_BIN_DIR)
  126. set(CTK_INSTALL_BIN_DIR "bin")
  127. endif()
  128. if(NOT CTK_INSTALL_LIB_DIR)
  129. set(CTK_INSTALL_LIB_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  130. endif()
  131. if(NOT CTK_INSTALL_INCLUDE_DIR)
  132. set(CTK_INSTALL_INCLUDE_DIR "include/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  133. endif()
  134. if(NOT CTK_INSTALL_DOC_DIR)
  135. set(CTK_INSTALL_DOC_DIR "doc")
  136. endif()
  137. #-----------------------------------------------------------------------------
  138. # Update CMake module path
  139. # Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
  140. #
  141. set(CMAKE_MODULE_PATH
  142. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
  143. "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  144. ${CMAKE_MODULE_PATH})
  145. #-----------------------------------------------------------------------------
  146. # Clear CTK_BASE_INCLUDE_DIRS, CTK_BASE_LIBRARIES and CTK_WRAPPED_LIBRARIES_PYTHONQT
  147. #
  148. set(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
  149. set(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  150. set(CTK_WRAPPED_LIBRARIES_PYTHONQT CACHE INTERNAL "CTK libraries wrapped using PythonQt" FORCE)
  151. # Variable use in CTKConfig.cmake.in
  152. set(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  153. set(${PROJECT_NAME}_PLUGIN_LIBRARIES CACHE INTERNAL "CTK plugins" FORCE)
  154. # Used by CTKGenerateCTKConfig.cmake and also used to reference script from other scripts
  155. set(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
  156. set(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
  157. #-----------------------------------------------------------------------------
  158. # CMake function(s) and macro(s)
  159. #
  160. include(CMake/ctkMacroParseArguments.cmake)
  161. include(CMake/ctkMacroSetPaths.cmake)
  162. include(CMake/ctkMacroListFilter.cmake)
  163. include(CMake/ctkMacroOptionUtils.cmake)
  164. include(CMake/ctkMacroBuildLib.cmake)
  165. include(CMake/ctkMacroBuildLibWrapper.cmake)
  166. include(CMake/ctkMacroBuildPlugin.cmake)
  167. include(CMake/ctkMacroBuildApp.cmake)
  168. include(CMake/ctkMacroBuildQtPlugin.cmake)
  169. include(CMake/ctkMacroCompilePythonScript.cmake)
  170. include(CMake/ctkMacroGenerateMocs.cmake)
  171. include(CMake/ctkMacroWrapPythonQt.cmake)
  172. include(CMake/ctkMacroSetupQt.cmake)
  173. include(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macros
  174. include(CMake/ctkFunctionExtractOptionNameAndValue.cmake)
  175. include(CMake/ctkMacroValidateBuildOptions.cmake)
  176. include(CMake/ctkMacroAddCtkLibraryOptions.cmake)
  177. include(CMake/ctkFunctionGenerateDGraphInput.cmake)
  178. include(CMake/ctkFunctionGenerateProjectXml.cmake)
  179. include(CMake/ctkFunctionGeneratePluginManifest.cmake)
  180. include(CMake/ctkMacroGeneratePluginResourceFile.cmake)
  181. include(CMake/ctkFunctionAddPluginRepo.cmake)
  182. include(CMake/ctkFunctionCheckCompilerFlags.cmake)
  183. include(CMake/ctkFunctionCheckoutRepo.cmake)
  184. include(CMake/ctkFunctionGetIncludeDirs.cmake)
  185. include(CMake/ctkFunctionGetLibraryDirs.cmake)
  186. include(CMake/ctkFunctionGetGccVersion.cmake)
  187. include(CMake/ctkFunctionGetCompilerVisibilityFlags.cmake)
  188. include(CMake/ctkFunctionCompileSnippets.cmake)
  189. #-----------------------------------------------------------------------------
  190. # Testing
  191. #
  192. include(CTest)
  193. mark_as_advanced(BUILD_TESTING)
  194. if(BUILD_TESTING)
  195. set(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  196. mark_as_advanced(TCL_TCLSH DART_ROOT)
  197. include(CMake/ctkMacroSimpleTest.cmake)
  198. include(CMake/ctkMacroSimpleTestWithData.cmake)
  199. # Setup file for setting custom ctest vars
  200. configure_file(
  201. CMake/CTestCustom.cmake.in
  202. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  203. @ONLY
  204. )
  205. # Configuration for the CMake-generated test driver
  206. set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  207. set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  208. try
  209. {")
  210. set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  211. catch( std::exception & excp )
  212. {
  213. fprintf(stderr,\"%s\\n\",excp.what());
  214. return EXIT_FAILURE;
  215. }
  216. catch( ... )
  217. {
  218. printf(\"Exception caught in the test driver\\n\");
  219. return EXIT_FAILURE;
  220. }
  221. ")
  222. endif()
  223. #-----------------------------------------------------------------------------
  224. # QtTesting
  225. #
  226. option(CTK_USE_QTTESTING "Enable/Disable QtTesting" OFF)
  227. mark_as_advanced(CTK_USE_QTTESTING)
  228. #-----------------------------------------------------------------------------
  229. # Coverage
  230. #
  231. option(WITH_COVERAGE "Enable/Disable coverage" OFF)
  232. mark_as_advanced(WITH_COVERAGE)
  233. #-----------------------------------------------------------------------------
  234. # Documentation
  235. #
  236. option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
  237. mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)
  238. set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  239. CACHE PATH "Where documentation archives should be stored")
  240. mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
  241. #-----------------------------------------------------------------------------
  242. # Additional CXX/C Flags
  243. #
  244. set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
  245. mark_as_advanced(ADDITIONAL_C_FLAGS)
  246. set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
  247. mark_as_advanced(ADDITIONAL_CXX_FLAGS)
  248. #-----------------------------------------------------------------------------
  249. # Set symbol visibility Flags
  250. #
  251. ctkFunctionGetCompilerVisibilityFlags(VISIBILITY_CXX_FLAGS)
  252. #-----------------------------------------------------------------------------
  253. # Set coverage Flags
  254. #
  255. if(WITH_COVERAGE)
  256. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  257. set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")
  258. set(COVERAGE_CXX_FLAGS ${coverage_flags})
  259. set(COVERAGE_C_FLAGS ${coverage_flags})
  260. endif()
  261. endif()
  262. #-----------------------------------------------------------------------------
  263. # CTK C/CXX Flags
  264. #
  265. set(CTK_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
  266. set(CTK_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
  267. if(CMAKE_COMPILER_IS_GNUCXX)
  268. set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings")
  269. if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  270. set(cflags "${cflags} -D_FORTIFY_SOURCE=2")
  271. endif()
  272. ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)
  273. ctkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags)
  274. ctkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
  275. # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so
  276. # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag.
  277. # Doing so should allow to build package made for distribution using older linux distro.
  278. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0"))
  279. ctkFunctionCheckCompilerFlags("-fstack-protector-all" cflags)
  280. endif()
  281. if(MINGW)
  282. # suppress warnings about auto imported symbols
  283. set(CTK_CXX_FLAGS "-Wl,--enable-auto-import ${CTK_CXX_FLAGS}")
  284. endif()
  285. set(CTK_C_FLAGS "${cflags} ${CTK_C_FLAGS}")
  286. set(CTK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${CTK_CXX_FLAGS}")
  287. endif()
  288. if(MSVC)
  289. set(msvc_suppressed_warnings
  290. "/wd4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  291. )
  292. set(CTK_CXX_FLAGS "${CTK_CXX_FLAGS} ${msvc_suppressed_warnings}")
  293. endif()
  294. #-----------------------------------------------------------------------------
  295. # QT
  296. #
  297. ctkMacroSetupQt()
  298. # Update CTK_BASE_LIBRARIES with QT libraries
  299. if(QT4_FOUND)
  300. set(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)
  301. endif()
  302. #-----------------------------------------------------------------------------
  303. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  304. # before the SuperBuild script is included
  305. #
  306. #-----------------------------------------------------------------------------
  307. # High-Level CTK options
  308. # The ctk_enable_option macro expects a logical expression after the first
  309. # three arguments. This expression should only contain build option names
  310. # which belong to leafs in the required dependency tree.
  311. # The CTK infrastructure for high-level DICOM support. This includes
  312. # DICOM indexing, networking, and GUI widgets.
  313. ctk_enable_option(DICOM "Enable default DICOM support" OFF
  314. CTK_LIB_DICOM/Widgets)
  315. # The CTK infrastructure for building a DICOM Part 19 compliant application
  316. # host and/or hosted application. This will not enable any example plugins
  317. # or executables (enable CTK_ENABLE_EXAMPLES for that).
  318. ctk_enable_option(DICOMApplicationHosting "Enable DICOM Part 19 Application Hosting support" OFF
  319. CTK_PLUGIN_org.commontk.dah.host AND CTK_PLUGIN_org.commontk.dah.hostedapp)
  320. # The CTK Qt Widgets. This will enable the Qt Widget library only.
  321. # It might trigger the enabling of other widget libraries in combination
  322. # with other enabled options.
  323. ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF
  324. CTK_LIB_Widgets)
  325. # The CTK Plugin Framework, a dynamic component system based on OSGi.
  326. # This will enable only the framework itself.
  327. ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF
  328. CTK_LIB_PluginFramework)
  329. #-----------------------------------------------------------------------------
  330. # Special "BUILD ALL" options
  331. # Build all CTK plug-ins
  332. option(CTK_BUILD_ALL_PLUGINS "Build all CTK plug-ins" OFF)
  333. # Build all CTK libraries
  334. option(CTK_BUILD_ALL_LIBRARIES "Build all CTK libraries" OFF)
  335. # Build all CTK applications
  336. option(CTK_BUILD_ALL_APPS "Build all CTK applications" OFF)
  337. # Build everything
  338. option(CTK_BUILD_ALL "Build everything in CTK" OFF)
  339. if(CTK_BUILD_ALL)
  340. set(CTK_BUILD_ALL_PLUGINS 1)
  341. set(CTK_BUILD_ALL_LIBRARIES 1)
  342. set(CTK_BUILD_ALL_APPS 1)
  343. endif()
  344. #-----------------------------------------------------------------------------
  345. # Other options
  346. # The CTK Python Wrapping
  347. ctk_enable_option(Python_Wrapping "Wrap CTK classes using Qt meta-object system into Python language" OFF
  348. CTK_LIB_Scripting/Python/Core)
  349. # Build examples
  350. # Create the logical expression containing the minium set of required options
  351. # for the CTK_BUILD_EXAMPLES option to be ON
  352. set(_build_examples_logical_expr)
  353. foreach(_app ${CTK_ENABLED_APPS})
  354. list(APPEND _build_examples_logical_expr CTK_APP_${_app} AND)
  355. endforeach()
  356. if(_build_examples_logical_expr)
  357. list(REMOVE_AT _build_examples_logical_expr -1)
  358. endif()
  359. ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF
  360. ${_build_examples_logical_expr})
  361. # Git protocol option
  362. option(CTK_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
  363. mark_as_advanced(CTK_USE_GIT_PROTOCOL)
  364. set(git_protocol "git")
  365. if(NOT CTK_USE_GIT_PROTOCOL)
  366. set(git_protocol "http")
  367. endif()
  368. # Let's mark as advanced some default properties
  369. mark_as_advanced(CMAKE_INSTALL_PREFIX)
  370. mark_as_advanced(DART_TESTING_TIMEOUT)
  371. # KWStyle
  372. option(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  373. mark_as_advanced(CTK_USE_KWSTYLE)
  374. # Qt Designer Plugins
  375. option(CTK_BUILD_QTDESIGNER_PLUGINS "Build Qt Designer plugins" ON)
  376. mark_as_advanced(CTK_BUILD_QTDESIGNER_PLUGINS)
  377. #-----------------------------------------------------------------------------
  378. # CTK Libraries
  379. #
  380. ctk_lib_option(Core
  381. "Build the Core library" ON)
  382. ctk_lib_option(PluginFramework
  383. "Build the Plugin Framework" OFF
  384. CTK_ENABLE_PluginFramework)
  385. ctk_lib_option(Widgets
  386. "Build the Widgets library" OFF
  387. CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES) OR CTK_USE_QTTESTING)
  388. ctk_lib_option(DICOM/Core
  389. "Build the DICOM Core library" OFF
  390. CTK_ENABLE_DICOM OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
  391. ctk_lib_option(DICOM/Widgets
  392. "Build the DICOM Widgets library" OFF
  393. CTK_ENABLE_DICOM AND CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
  394. ctk_lib_option(ImageProcessing/ITK/Core
  395. "Build the ITK Core library" OFF)
  396. ctk_lib_option(Scripting/Python/Core
  397. "Build the Python Core library" OFF)
  398. ctk_lib_option(Scripting/Python/Widgets
  399. "Build the Python Widgets library" OFF
  400. CTK_LIB_Widgets AND CTK_ENABLE_Python_Wrapping)
  401. ctk_lib_option(Visualization/VTK/Core
  402. "Build the VTK Core library" OFF)
  403. ctk_lib_option(Visualization/VTK/Widgets
  404. "Build the VTK Widgets library" OFF)
  405. ctk_lib_option(CommandLineModules/Core
  406. "Build the Command Line Module core library" OFF)
  407. ctk_lib_option(CommandLineModules/Frontend/QtWebKit
  408. "Build the QtWebKit based Command Line Module front-end" OFF)
  409. ctk_lib_option(CommandLineModules/Frontend/QtGui
  410. "Build the QtGui based Command Line Module front-end" OFF)
  411. ctk_lib_option(CommandLineModules/Backend/LocalProcess
  412. "Build the Command Line Module back-end for local processes" OFF)
  413. ctk_lib_option(CommandLineModules/Backend/FunctionPointer
  414. "Build the Command Line Module back-end for function pointers" OFF)
  415. #ctk_lib_option(Visualization/XIP
  416. # "Build the XIP library" OFF)
  417. # Save the set of enabled libs in a cache file
  418. set(_enabled_libs)
  419. foreach(_lib ${CTK_LIBS})
  420. if(CTK_LIB_${_lib})
  421. list(APPEND _enabled_libs ${_lib})
  422. endif()
  423. endforeach()
  424. set(CTK_ENABLED_LIBS ${_enabled_libs} CACHE INTERNAL "" FORCE)
  425. #-----------------------------------------------------------------------------
  426. # CTK Applications - Use ON or OFF to indicate if the application should be built by default
  427. #
  428. ctk_app_option(ctkDICOM
  429. "Build the DICOM example application" OFF
  430. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  431. ctk_app_option(ctkDICOM2
  432. "Build the new DICOM example application (experimental)" OFF
  433. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  434. ctk_app_option(ctkDICOMIndexer
  435. "Build the DICOM example application" OFF
  436. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  437. ctk_app_option(ctkDICOMDemoSCU
  438. "Build the DICOM example application" OFF
  439. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  440. ctk_app_option(ctkDICOMQuery
  441. "Build the DICOM example application" OFF
  442. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  443. ctk_app_option(ctkDICOMRetrieve
  444. "Build the DICOM example application" OFF
  445. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  446. ctk_app_option(ctkDICOMQueryRetrieve
  447. "Build the DICOM example application" OFF
  448. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  449. ctk_app_option(ctkDICOMHost
  450. "Build the DICOM application host example application" OFF
  451. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  452. ctk_app_option(ctkExampleHost
  453. "Build the DICOM example application" OFF
  454. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  455. ctk_app_option(ctkExampleHostedApp
  456. "Build the DICOM example application" OFF
  457. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  458. ctk_app_option(ctkEventBusDemo
  459. "Build the DICOM example application" OFF
  460. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  461. ctk_app_option(ctkCommandLineModuleExplorer
  462. "Build the Command Line Module Explorer" OFF
  463. CTK_BUILD_EXAMPLES)
  464. # We use the CTKWidgets library together with the Qt Designer plug-in
  465. # in ctkCommandLineModuleExplorer, so enabling the options here.
  466. # (We do not need to link them into the executable, hence no entries
  467. # in target_libraries.cmake)
  468. if(CTK_APP_ctkCommandLineModuleExplorer)
  469. foreach(_option CTK_BUILD_QTDESIGNER_PLUGINS)
  470. if(NOT ${_option})
  471. get_property(_docstring CACHE ${_option} PROPERTY HELPSTRING)
  472. set(${_option} ON CACHE BOOL "${_docstring}" FORCE)
  473. message("Enabling option [${_option}] required by [ctkCommandLineModuleExplorer]")
  474. endif()
  475. endforeach()
  476. endif()
  477. ctk_app_option(ctkPluginBrowser
  478. "Build the DICOM example application" OFF
  479. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  480. ctk_app_option(ctkPluginGenerator
  481. "Build the DICOM example application" OFF
  482. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  483. ctk_app_option(ctkDICOMObjectViewer
  484. "Build the DICOM example application" OFF
  485. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  486. ctk_app_option(ctkSimplePythonShell
  487. "Build the DICOM example application" OFF
  488. CTK_ENABLE_Python_Wrapping AND CTK_BUILD_EXAMPLES)
  489. if(CTK_USE_QTTESTING)
  490. ctk_app_option(ctkQtTesting
  491. "Build the ctkQtTesting example application" OFF
  492. CTK_BUILD_EXAMPLES)
  493. endif()
  494. # Save the set of enabled apps in a cache file
  495. set(_enabled_apps)
  496. foreach(_app ${CTK_APPS})
  497. if(CTK_APP_${_app})
  498. list(APPEND _enabled_apps ${_app})
  499. endif()
  500. endforeach()
  501. set(CTK_ENABLED_APPS ${_enabled_apps} CACHE INTERNAL "" FORCE)
  502. #-----------------------------------------------------------------------------
  503. # CTK Plugins - none of them is build by default
  504. #
  505. # Plugins in the list below are not build by default
  506. set(plugin_list
  507. # Optional plug-ins implementings interfaces in PluginFramework/service/
  508. org.commontk.configadmin
  509. org.commontk.eventadmin
  510. org.commontk.log
  511. org.commontk.log4qt
  512. org.commontk.metatype
  513. )
  514. foreach(_plugin ${plugin_list})
  515. ctk_plugin_option(${_plugin} "Build the ${_plugin} plugin." OFF)
  516. endforeach()
  517. # Plug-ins related to the PluginGenerator application
  518. ctk_plugin_option(org.commontk.plugingenerator.core "Build the org.commontk.plugingenerator.core plugin." OFF)
  519. ctk_plugin_option(org.commontk.plugingenerator.ui
  520. "Build the org.commontk.plugingenerator.ui plugin." OFF
  521. CTK_APP_ctkPluginGenerator)
  522. # Plug-ins related to DICOM WG23 (Application Hosting)
  523. ctk_plugin_option(org.commontk.dah.core "Build the org.commontk.dah.core plugin." OFF)
  524. ctk_plugin_option(org.commontk.dah.hostedapp "Build the org.commontk.dah.hostedapp plugin." OFF
  525. CTK_ENABLE_DICOMApplicationHosting)
  526. ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin." OFF
  527. CTK_ENABLE_DICOMApplicationHosting)
  528. ctk_plugin_option(org.commontk.dah.exampleapp
  529. "Build the org.commontk.dah.exampleapp plugin." OFF
  530. CTK_APP_ctkExampleHostedApp)
  531. ctk_plugin_option(org.commontk.dah.cmdlinemoduleapp
  532. "Build the org.commontk.dah.cmdlinemoduleapp plugin." OFF
  533. CTK_APP_ctkCommandLineModuleApp)
  534. ctk_plugin_option(org.commontk.dah.examplehost
  535. "Build the org.commontk.dah.examplehost plugin." OFF
  536. CTK_APP_ctkExampleHost)
  537. # Plug-ins related to the EventBus demo application
  538. ctk_plugin_option(org.commontk.eventbus
  539. "Build the org.commontk.eventbus plugin." OFF
  540. CTK_APP_ctkEventBusDemo)
  541. # Add the PluginsContrib repo to the build system
  542. option(CTK_USE_CONTRIBUTED_PLUGINS OFF "Use CTK plug-ins from the PluginsContrib repository")
  543. mark_as_advanced(CTK_USE_CONTRIBUTED_PLUGINS)
  544. if(CTK_USE_CONTRIBUTED_PLUGINS)
  545. ctkFunctionAddPluginRepo(NAME PluginsContrib
  546. GIT_URL github.com/commontk/PluginsContrib.git
  547. GIT_TAG 7fc37f400c
  548. )
  549. endif()
  550. #-----------------------------------------------------------------------------
  551. # Generate target_directories list - List of directory corresponding to the different
  552. # libraries, plugins and applications associated with the corresponding option name.
  553. #
  554. # The following FOREACH loops are used to:
  555. # 1) Update either CTK_LIBS_SUBDIRS, CTK_PLUGINS_SUBDIRS or CTK_APPS_SUBDIRS variables
  556. #
  557. # For CTK libraries, if the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists,
  558. # in addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
  559. # will also be available in CMake configure menu:
  560. # CTK_LIB_<DIR>/<LIBNAME>_OPT1 (set to OFF)
  561. # CTK_LIB_<DIR>/<LIBNAME>_OPT2 (set to ON)
  562. #
  563. # The file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake should look like:
  564. #
  565. # set(ctk_library_options
  566. # OPT1:OFF
  567. # OPT2:ON
  568. # )
  569. # Create list of directories corresponding to the enabled targets
  570. set(target_directories)
  571. set(ctk_lib_options_list) # This list will be updated in ctkMacroAddCtkLibraryOptions
  572. foreach(lib ${CTK_LIBS})
  573. if(CTK_LIB_${lib})
  574. ctkMacroAddCtkLibraryOptions(${lib})
  575. endif()
  576. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^CTK_LIB_${lib}")
  577. endforeach()
  578. foreach(plugin ${CTK_PLUGINS})
  579. if(${plugin}_SOURCE_DIR)
  580. list(APPEND target_directories "${${plugin}_SOURCE_DIR}^^CTK_PLUGIN_${plugin}")
  581. else()
  582. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^CTK_PLUGIN_${plugin}")
  583. endif()
  584. endforeach()
  585. foreach(app ${CTK_APPS})
  586. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^CTK_APP_${app}")
  587. endforeach()
  588. #message(STATUS target_directories:${target_directories})
  589. #-----------------------------------------------------------------------------
  590. # Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
  591. # topological order.
  592. try_compile(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
  593. DGraph
  594. CMAKE_FLAGS
  595. -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  596. -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
  597. -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}
  598. -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
  599. OUTPUT_VARIABLE output)
  600. if(NOT RESULT_VAR)
  601. message(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
  602. endif()
  603. find_program(DGraph_EXECUTABLE DGraph
  604. "${CTK_BINARY_DIR}/Utilities/DGraph/"
  605. "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
  606. "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
  607. "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
  608. mark_as_advanced(DGraph_EXECUTABLE)
  609. #-----------------------------------------------------------------------------
  610. # Let's make sure the enabled/disabled libraries, plugins or applications are coherent
  611. #
  612. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}")
  613. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_EXTERNALS)
  614. ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
  615. #-----------------------------------------------------------------------------
  616. # CTK Python wrapping
  617. # Enable CTK_LIB_Scripting/Python/Core if either CTK_ENABLE_Python_Wrapping OR CTK_WRAP_PYTHONQT_FULL
  618. #
  619. set(CTK_WRAP_PYTHONQT_LIGHT ${CTK_ENABLE_Python_Wrapping})
  620. option(CTK_WRAP_PYTHONQT_FULL "Experimental - Wrap CTK classes using Qt meta-object system into Python language" OFF)
  621. mark_as_advanced(CTK_WRAP_PYTHONQT_FULL)
  622. if(CTK_WRAP_PYTHONQT_FULL AND CTK_WRAP_PYTHONQT_LIGHT)
  623. message(FATAL_ERROR "CTK_ENABLE_Python_Wrapping AND CTK_WRAP_PYTHONQT_FULL options are mutually exclusive. Please enable only one !")
  624. endif()
  625. set(logical_expr CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL)
  626. if((${logical_expr}) AND NOT CTK_LIB_Scripting/Python/Core)
  627. set(CTK_LIB_Scripting/Python/Core ON CACHE BOOL "Build the Python Core library" FORCE)
  628. set(enabling_msg)
  629. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  630. message("Enabling [CTK_LIB_Scripting/Python/Core] because of [${enabling_msg}] evaluates to True")
  631. endif()
  632. set(logical_expr CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  633. if(${logical_expr} AND NOT CTK_LIB_Visualization/VTK/Core)
  634. set(CTK_LIB_Visualization/VTK/Core ON CACHE BOOL "Build the VTK Core library" FORCE)
  635. set(enabling_msg)
  636. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  637. message("Enabling [CTK_LIB_Visualization/VTK/Core] because of [${enabling_msg}] evaluates to True")
  638. endif()
  639. # Check if dependencies are satisfied
  640. if(CTK_LIB_Scripting/Python/Core)
  641. find_package(PythonInterp)
  642. if(NOT PYTHONINTERP_FOUND)
  643. message(FATAL_ERROR "PYTHON_EXECUTABLE variable should be set to build CTK_LIB_Scripting/Python")
  644. endif()
  645. find_package(PythonLibs)
  646. if(NOT PYTHONLIBS_FOUND)
  647. message(FATAL_ERROR "PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS should be set to build CTK_LIB_Scripting/Python")
  648. endif()
  649. endif()
  650. #-----------------------------------------------------------------------------
  651. # DGraph
  652. #
  653. # Generate DGraph input file expected by DGraph
  654. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_OPTION)
  655. # Obtain list of target ordered topologically
  656. ctkMacroSetPaths("${QT_INSTALLED_LIBRARY_DIR}")
  657. execute_process(
  658. COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
  659. WORKING_DIRECTORY ${CTK_BINARY_DIR}
  660. RESULT_VARIABLE RESULT_VAR
  661. OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS_OUTPUT
  662. ERROR_VARIABLE error
  663. OUTPUT_STRIP_TRAILING_WHITESPACE
  664. )
  665. if(RESULT_VAR)
  666. message(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
  667. endif()
  668. # Convert 'CTEST_PROJECT_SUBPROJECTS_OUTPUT' to a list
  669. string(REPLACE " " "\\;" CTEST_PROJECT_SUBPROJECTS "${CTEST_PROJECT_SUBPROJECTS_OUTPUT}")
  670. set(CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS})
  671. # If the list of subproject is empty, let's at least build CTKCore
  672. list(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
  673. IF (subproject_count EQUAL 0)
  674. set(CTEST_PROJECT_SUBPROJECTS CTKCore)
  675. endif()
  676. # Configure CTestConfigSubProject.cmake that could be used by CTest scripts
  677. configure_file(${CTK_SOURCE_DIR}/CMake/CTestConfigSubProject.cmake.in
  678. ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
  679. #-----------------------------------------------------------------------------
  680. # Project.xml
  681. #
  682. # Generate Project.xml file expected by the CTest driver script
  683. ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
  684. #-----------------------------------------------------------------------------
  685. # CTK dependencies - Projects should be TOPOLOGICALLY ordered
  686. #-----------------------------------------------------------------------------
  687. set(CTK_POSSIBLE_DEPENDENCIES
  688. CTKData
  689. QtTesting
  690. Log4Qt
  691. KWStyle
  692. VTK
  693. PythonQt
  694. PythonQtGenerator # Should be added after PythonQt - See comment in CMakeExternals/PythonQtGenerator.cmake
  695. DCMTK
  696. ZMQ
  697. QtSOAP
  698. qxmlrpc
  699. OpenIGTLink
  700. XIP
  701. ITK
  702. )
  703. #-----------------------------------------------------------------------------
  704. # Check out the ExternalProjectsContrib repository
  705. if(CTK_USE_CONTRIBUTED_PLUGINS)
  706. if(CTK_SUPERBUILD)
  707. ctkFunctionCheckoutRepo(
  708. NAME ExternalProjectsContrib
  709. GIT_URL github.com/commontk/ExternalProjectsContrib.git
  710. GIT_TAG c15781914f
  711. )
  712. endif()
  713. file(GLOB _contrib_scripts ${ExternalProjectsContrib_DIR}/*.cmake)
  714. foreach(_contrib_script ${_contrib_scripts})
  715. get_filename_component(_script_name ${_contrib_script} NAME_WE)
  716. list(APPEND CTK_POSSIBLE_DEPENDENCIES ${_script_name})
  717. set(${_script_name}_FILEPATH ${_contrib_script})
  718. endforeach()
  719. endif()
  720. set(CTK_DEPENDENCIES) # This variable will contain the list of required CTK dependencies
  721. include(CMake/ctkBlockCheckDependencies.cmake)
  722. #-----------------------------------------------------------------------------
  723. # Superbuild script
  724. #
  725. if(CTK_SUPERBUILD)
  726. include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  727. return()
  728. endif()
  729. #-----------------------------------------------------------------------------
  730. # Expand variables containing include and library directories for external projects
  731. # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions
  732. foreach(_external_target ${EXTERNAL_TARGETS})
  733. if(${_external_target}_FIND_PACKAGE_CMD)
  734. #message("Calling find_package(${${_external_target}_FIND_PACKAGE_CMD})")
  735. find_package(${${_external_target}_FIND_PACKAGE_CMD} REQUIRED)
  736. endif()
  737. endforeach()
  738. foreach(_external_target ${EXTERNAL_TARGETS})
  739. if(${_external_target}_INCLUDE_DIRS)
  740. #message("[${_external_target}] Resolving include variables: ${${_external_target}_INCLUDE_DIRS}")
  741. foreach(_include_variable ${${_external_target}_INCLUDE_DIRS})
  742. #message("[${_external_target}] Appending ${${_include_variable}}")
  743. if(${_include_variable})
  744. list(APPEND ${_external_target}_INCLUDE_DIRS ${${_include_variable}})
  745. else()
  746. list(APPEND ${_external_target}_INCLUDE_DIRS ${_include_variable})
  747. endif()
  748. #message("[${_external_target}] New dirs: ${${_external_target}_INCLUDE_DIRS}")
  749. endforeach()
  750. #message("[${_external_target}] Appended dirs: ${${_external_target}_INCLUDE_DIRS}")
  751. endif()
  752. if(${_external_target}_LIBRARY_DIRS)
  753. #message("[${_external_target}] Resolving library variables: ${${_external_target}_LIBRARY_DIRS}")
  754. foreach(_library_variable ${${_external_target}_LIBRARY_DIRS})
  755. #message("[${_external_target}] Appending ${${_library_variable}}")
  756. if(${_library_variable})
  757. list(APPEND ${_external_target}_LIBRARY_DIRS ${${_library_variable}})
  758. else()
  759. list(APPEND ${_external_target}_LIBRARY_DIRS ${_library_variable})
  760. endif()
  761. #message("[${_external_target}] New dirs: ${${_external_target}_LIBRARY_DIRS}")
  762. endforeach()
  763. #message("[${_external_target}] Appended dirs: ${${_external_target}_LIBRARY_DIRS}")
  764. endif()
  765. endforeach()
  766. set(CTK_WRAP_PYTHONQT_USE_VTK ${CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK})
  767. #-----------------------------------------------------------------------------
  768. # CTK_SUPERBUILD_BINARY_DIR
  769. # If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
  770. # In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
  771. if(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
  772. set(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
  773. endif()
  774. #-----------------------------------------------------------------------------
  775. # Configure files with settings
  776. #
  777. configure_file(${CTK_SOURCE_DIR}/CMake/UseCTK.cmake.in
  778. ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
  779. set(CTK_CONFIG_H_INCLUDE_DIR ${CTK_BINARY_DIR})
  780. #-----------------------------------------------------------------------------
  781. # Set C/CXX Flags
  782. #
  783. set(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)
  784. set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
  785. #-----------------------------------------------------------------------------
  786. # Set the header template which defines custom export/import macros
  787. # for shared libraries
  788. #
  789. set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")
  790. #-----------------------------------------------------------------------------
  791. # Setup testing environment before Libs are added
  792. #
  793. add_subdirectory(Libs/Testing)
  794. #-----------------------------------------------------------------------------
  795. # Add CTK library subdirectories
  796. #
  797. foreach(lib ${CTK_LIBS})
  798. if(CTK_LIB_${lib})
  799. add_subdirectory(Libs/${lib})
  800. endif()
  801. # Always add the Documentation sub-directory for additional processing
  802. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation/CMakeLists.txt)
  803. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation)
  804. endif()
  805. endforeach()
  806. # Add the CommandLineModules root directory for additional processing
  807. add_subdirectory(Libs/CommandLineModules)
  808. #-----------------------------------------------------------------------------
  809. if(CTK_USE_QTTESTING)
  810. add_subdirectory(Libs/QtTesting)
  811. endif()
  812. #-----------------------------------------------------------------------------
  813. # Add CTK plugin subdirectories
  814. #
  815. foreach(plugin ${CTK_PLUGINS})
  816. if(CTK_PLUGIN_${plugin})
  817. if(${plugin}_SOURCE_DIR)
  818. add_subdirectory(${${plugin}_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Plugins/${plugin})
  819. else()
  820. add_subdirectory(Plugins/${plugin})
  821. endif()
  822. endif()
  823. endforeach()
  824. #-----------------------------------------------------------------------------
  825. # Add CTK application subdirectories
  826. #
  827. foreach(app ${CTK_APPS})
  828. IF (CTK_APP_${app})
  829. add_subdirectory(Applications/${app})
  830. endif()
  831. endforeach()
  832. if(BUILD_TESTING)
  833. add_subdirectory(Applications/Testing)
  834. endif()
  835. #-----------------------------------------------------------------------------
  836. # Add general purpose subdirectories
  837. #
  838. #add_subdirectory(Testing)
  839. #add_subdirectory(Examples)
  840. #-----------------------------------------------------------------------------
  841. # Style Checking configuration
  842. #
  843. include(Utilities/KWStyle/KWStyle.cmake)
  844. #---------------------------------------------------------------------------
  845. # Documentation
  846. #
  847. add_subdirectory( Documentation )
  848. #-----------------------------------------------------------------------------
  849. # The commands in this directory are intended to be executed as
  850. # the end of the whole configuration process, as a "last step".
  851. # This directory is typically the last SUBDIRS in the main CMakeLists.txt.
  852. add_subdirectory(CMake/LastConfigureStep)