CMakeLists.txt 40 KB

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