CMakeLists.txt 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  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(XNAT/Core
  416. "Build the XNAT Core library" OFF)
  417. ctk_lib_option(XNAT/Widgets
  418. "Build the XNAT Widgets library" OFF)
  419. #ctk_lib_option(Visualization/XIP
  420. # "Build the XIP library" OFF)
  421. # Save the set of enabled libs in a cache file
  422. set(_enabled_libs)
  423. foreach(_lib ${CTK_LIBS})
  424. if(CTK_LIB_${_lib})
  425. list(APPEND _enabled_libs ${_lib})
  426. endif()
  427. endforeach()
  428. set(CTK_ENABLED_LIBS ${_enabled_libs} CACHE INTERNAL "" FORCE)
  429. #-----------------------------------------------------------------------------
  430. # CTK Applications - Use ON or OFF to indicate if the application should be built by default
  431. #
  432. ctk_app_option(ctkDICOM
  433. "Build the DICOM example application" OFF
  434. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  435. ctk_app_option(ctkDICOM2
  436. "Build the new DICOM example application (experimental)" OFF
  437. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  438. ctk_app_option(ctkDICOMIndexer
  439. "Build the DICOM example application" OFF
  440. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  441. ctk_app_option(ctkDICOMDemoSCU
  442. "Build the DICOM example application" OFF
  443. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  444. ctk_app_option(ctkDICOMQuery
  445. "Build the DICOM example application" OFF
  446. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  447. ctk_app_option(ctkDICOMRetrieve
  448. "Build the DICOM example application" OFF
  449. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  450. ctk_app_option(ctkDICOMQueryRetrieve
  451. "Build the DICOM example application" OFF
  452. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  453. ctk_app_option(ctkDICOMHost
  454. "Build the DICOM application host example application" OFF
  455. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  456. ctk_app_option(ctkExampleHost
  457. "Build the DICOM example application" OFF
  458. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  459. ctk_app_option(ctkExampleHostedApp
  460. "Build the DICOM example application" OFF
  461. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  462. ctk_app_option(ctkEventBusDemo
  463. "Build the DICOM example application" OFF
  464. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  465. ctk_app_option(ctkCommandLineModuleExplorer
  466. "Build the Command Line Module Explorer" OFF
  467. CTK_BUILD_EXAMPLES)
  468. # We use the CTKWidgets library together with the Qt Designer plug-in
  469. # in ctkCommandLineModuleExplorer, so enabling the options here.
  470. # (We do not need to link them into the executable, hence no entries
  471. # in target_libraries.cmake)
  472. if(CTK_APP_ctkCommandLineModuleExplorer)
  473. foreach(_option CTK_BUILD_QTDESIGNER_PLUGINS)
  474. if(NOT ${_option})
  475. get_property(_docstring CACHE ${_option} PROPERTY HELPSTRING)
  476. set(${_option} ON CACHE BOOL "${_docstring}" FORCE)
  477. message("Enabling option [${_option}] required by [ctkCommandLineModuleExplorer]")
  478. endif()
  479. endforeach()
  480. endif()
  481. ctk_app_option(ctkPluginBrowser
  482. "Build the DICOM example application" OFF
  483. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  484. ctk_app_option(ctkPluginGenerator
  485. "Build the DICOM example application" OFF
  486. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  487. ctk_app_option(ctkDICOMObjectViewer
  488. "Build the DICOM example application" OFF
  489. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  490. ctk_app_option(ctkSimplePythonShell
  491. "Build the DICOM example application" OFF
  492. CTK_ENABLE_Python_Wrapping AND CTK_BUILD_EXAMPLES)
  493. if(CTK_USE_QTTESTING)
  494. ctk_app_option(ctkQtTesting
  495. "Build the ctkQtTesting example application" OFF
  496. CTK_BUILD_EXAMPLES)
  497. endif()
  498. ctk_app_option(ctkXNATBrowser
  499. "Build the XNAT Browser application" OFF
  500. CTK_BUILD_EXAMPLES)
  501. ctk_app_option(ctkXnatTreeBrowser
  502. "Build the XNAT Tree Browser application" OFF
  503. CTK_BUILD_EXAMPLES)
  504. # Save the set of enabled apps in a cache file
  505. set(_enabled_apps)
  506. foreach(_app ${CTK_APPS})
  507. if(CTK_APP_${_app})
  508. list(APPEND _enabled_apps ${_app})
  509. endif()
  510. endforeach()
  511. set(CTK_ENABLED_APPS ${_enabled_apps} CACHE INTERNAL "" FORCE)
  512. #-----------------------------------------------------------------------------
  513. # CTK Plugins - none of them is build by default
  514. #
  515. # Plugins in the list below are not build by default
  516. set(plugin_list
  517. # Optional plug-ins implementings interfaces in PluginFramework/service/
  518. org.commontk.configadmin
  519. org.commontk.eventadmin
  520. org.commontk.log
  521. org.commontk.log4qt
  522. org.commontk.metatype
  523. )
  524. foreach(_plugin ${plugin_list})
  525. ctk_plugin_option(${_plugin} "Build the ${_plugin} plugin." OFF)
  526. endforeach()
  527. # Plug-ins related to the PluginGenerator application
  528. ctk_plugin_option(org.commontk.plugingenerator.core "Build the org.commontk.plugingenerator.core plugin." OFF)
  529. ctk_plugin_option(org.commontk.plugingenerator.ui
  530. "Build the org.commontk.plugingenerator.ui plugin." OFF
  531. CTK_APP_ctkPluginGenerator)
  532. # Plug-ins related to DICOM WG23 (Application Hosting)
  533. ctk_plugin_option(org.commontk.dah.core "Build the org.commontk.dah.core plugin." OFF)
  534. ctk_plugin_option(org.commontk.dah.hostedapp "Build the org.commontk.dah.hostedapp plugin." OFF
  535. CTK_ENABLE_DICOMApplicationHosting)
  536. ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin." OFF
  537. CTK_ENABLE_DICOMApplicationHosting)
  538. ctk_plugin_option(org.commontk.dah.exampleapp
  539. "Build the org.commontk.dah.exampleapp plugin." OFF
  540. CTK_APP_ctkExampleHostedApp)
  541. ctk_plugin_option(org.commontk.dah.cmdlinemoduleapp
  542. "Build the org.commontk.dah.cmdlinemoduleapp plugin." OFF
  543. CTK_APP_ctkCommandLineModuleApp)
  544. ctk_plugin_option(org.commontk.dah.examplehost
  545. "Build the org.commontk.dah.examplehost plugin." OFF
  546. CTK_APP_ctkExampleHost)
  547. # Plug-ins related to the EventBus demo application
  548. ctk_plugin_option(org.commontk.eventbus
  549. "Build the org.commontk.eventbus plugin." OFF
  550. CTK_APP_ctkEventBusDemo)
  551. # Add the PluginsContrib repo to the build system
  552. option(CTK_USE_CONTRIBUTED_PLUGINS OFF "Use CTK plug-ins from the PluginsContrib repository")
  553. mark_as_advanced(CTK_USE_CONTRIBUTED_PLUGINS)
  554. if(CTK_USE_CONTRIBUTED_PLUGINS)
  555. ctkFunctionAddPluginRepo(NAME PluginsContrib
  556. GIT_URL github.com/commontk/PluginsContrib.git
  557. GIT_TAG 7fc37f400c
  558. )
  559. endif()
  560. #-----------------------------------------------------------------------------
  561. # Generate target_directories list - List of directory corresponding to the different
  562. # libraries, plugins and applications associated with the corresponding option name.
  563. #
  564. # The following FOREACH loops are used to:
  565. # 1) Update either CTK_LIBS_SUBDIRS, CTK_PLUGINS_SUBDIRS or CTK_APPS_SUBDIRS variables
  566. #
  567. # For CTK libraries, if the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists,
  568. # in addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
  569. # will also be available in CMake configure menu:
  570. # CTK_LIB_<DIR>/<LIBNAME>_OPT1 (set to OFF)
  571. # CTK_LIB_<DIR>/<LIBNAME>_OPT2 (set to ON)
  572. #
  573. # The file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake should look like:
  574. #
  575. # set(ctk_library_options
  576. # OPT1:OFF
  577. # OPT2:ON
  578. # )
  579. # Create list of directories corresponding to the enabled targets
  580. set(target_directories)
  581. set(ctk_lib_options_list) # This list will be updated in ctkMacroAddCtkLibraryOptions
  582. foreach(lib ${CTK_LIBS})
  583. if(CTK_LIB_${lib})
  584. ctkMacroAddCtkLibraryOptions(${lib})
  585. endif()
  586. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^CTK_LIB_${lib}")
  587. endforeach()
  588. foreach(plugin ${CTK_PLUGINS})
  589. if(${plugin}_SOURCE_DIR)
  590. list(APPEND target_directories "${${plugin}_SOURCE_DIR}^^CTK_PLUGIN_${plugin}")
  591. else()
  592. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^CTK_PLUGIN_${plugin}")
  593. endif()
  594. endforeach()
  595. foreach(app ${CTK_APPS})
  596. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^CTK_APP_${app}")
  597. endforeach()
  598. #message(STATUS target_directories:${target_directories})
  599. #-----------------------------------------------------------------------------
  600. # Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
  601. # topological order.
  602. try_compile(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
  603. DGraph
  604. CMAKE_FLAGS
  605. -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  606. -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
  607. -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}
  608. -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
  609. OUTPUT_VARIABLE output)
  610. if(NOT RESULT_VAR)
  611. message(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
  612. endif()
  613. find_program(DGraph_EXECUTABLE DGraph
  614. "${CTK_BINARY_DIR}/Utilities/DGraph/"
  615. "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
  616. "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
  617. "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
  618. mark_as_advanced(DGraph_EXECUTABLE)
  619. #-----------------------------------------------------------------------------
  620. # Let's make sure the enabled/disabled libraries, plugins or applications are coherent
  621. #
  622. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}")
  623. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_EXTERNALS)
  624. ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
  625. #-----------------------------------------------------------------------------
  626. # CTK Python wrapping
  627. # Enable CTK_LIB_Scripting/Python/Core if either CTK_ENABLE_Python_Wrapping OR CTK_WRAP_PYTHONQT_FULL
  628. #
  629. set(CTK_WRAP_PYTHONQT_LIGHT ${CTK_ENABLE_Python_Wrapping})
  630. option(CTK_WRAP_PYTHONQT_FULL "Experimental - Wrap CTK classes using Qt meta-object system into Python language" OFF)
  631. mark_as_advanced(CTK_WRAP_PYTHONQT_FULL)
  632. if(CTK_WRAP_PYTHONQT_FULL AND CTK_WRAP_PYTHONQT_LIGHT)
  633. message(FATAL_ERROR "CTK_ENABLE_Python_Wrapping AND CTK_WRAP_PYTHONQT_FULL options are mutually exclusive. Please enable only one !")
  634. endif()
  635. set(logical_expr CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL)
  636. if((${logical_expr}) AND NOT CTK_LIB_Scripting/Python/Core)
  637. set(CTK_LIB_Scripting/Python/Core ON CACHE BOOL "Build the Python Core library" FORCE)
  638. set(enabling_msg)
  639. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  640. message("Enabling [CTK_LIB_Scripting/Python/Core] because of [${enabling_msg}] evaluates to True")
  641. endif()
  642. set(logical_expr CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  643. if(${logical_expr} AND NOT CTK_LIB_Visualization/VTK/Core)
  644. set(CTK_LIB_Visualization/VTK/Core ON CACHE BOOL "Build the VTK Core library" FORCE)
  645. set(enabling_msg)
  646. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  647. message("Enabling [CTK_LIB_Visualization/VTK/Core] because of [${enabling_msg}] evaluates to True")
  648. endif()
  649. # Check if dependencies are satisfied
  650. if(CTK_LIB_Scripting/Python/Core)
  651. find_package(PythonInterp)
  652. if(NOT PYTHONINTERP_FOUND)
  653. message(FATAL_ERROR "PYTHON_EXECUTABLE variable should be set to build CTK_LIB_Scripting/Python")
  654. endif()
  655. find_package(PythonLibs)
  656. if(NOT PYTHONLIBS_FOUND)
  657. message(FATAL_ERROR "PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS should be set to build CTK_LIB_Scripting/Python")
  658. endif()
  659. endif()
  660. #-----------------------------------------------------------------------------
  661. # DGraph
  662. #
  663. # Generate DGraph input file expected by DGraph
  664. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_OPTION)
  665. # Obtain list of target ordered topologically
  666. ctkMacroSetPaths("${QT_INSTALLED_LIBRARY_DIR}")
  667. execute_process(
  668. COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
  669. WORKING_DIRECTORY ${CTK_BINARY_DIR}
  670. RESULT_VARIABLE RESULT_VAR
  671. OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS_OUTPUT
  672. ERROR_VARIABLE error
  673. OUTPUT_STRIP_TRAILING_WHITESPACE
  674. )
  675. if(RESULT_VAR)
  676. message(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
  677. endif()
  678. # Convert 'CTEST_PROJECT_SUBPROJECTS_OUTPUT' to a list
  679. string(REPLACE " " "\\;" CTEST_PROJECT_SUBPROJECTS "${CTEST_PROJECT_SUBPROJECTS_OUTPUT}")
  680. set(CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS})
  681. # If the list of subproject is empty, let's at least build CTKCore
  682. list(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
  683. IF (subproject_count EQUAL 0)
  684. set(CTEST_PROJECT_SUBPROJECTS CTKCore)
  685. endif()
  686. # Configure CTestConfigSubProject.cmake that could be used by CTest scripts
  687. configure_file(${CTK_SOURCE_DIR}/CMake/CTestConfigSubProject.cmake.in
  688. ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
  689. #-----------------------------------------------------------------------------
  690. # Project.xml
  691. #
  692. # Generate Project.xml file expected by the CTest driver script
  693. ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
  694. #-----------------------------------------------------------------------------
  695. # CTK dependencies - Projects should be TOPOLOGICALLY ordered
  696. #-----------------------------------------------------------------------------
  697. set(CTK_POSSIBLE_DEPENDENCIES
  698. CTKData
  699. QtTesting
  700. Log4Qt
  701. KWStyle
  702. VTK
  703. PythonQt
  704. PythonQtGenerator # Should be added after PythonQt - See comment in CMakeExternals/PythonQtGenerator.cmake
  705. DCMTK
  706. ZMQ
  707. QtSOAP
  708. qxmlrpc
  709. qRestAPI
  710. OpenIGTLink
  711. XIP
  712. ITK
  713. )
  714. #-----------------------------------------------------------------------------
  715. # Check out the ExternalProjectsContrib repository
  716. if(CTK_USE_CONTRIBUTED_PLUGINS)
  717. if(CTK_SUPERBUILD)
  718. ctkFunctionCheckoutRepo(
  719. NAME ExternalProjectsContrib
  720. GIT_URL github.com/commontk/ExternalProjectsContrib.git
  721. GIT_TAG c15781914f
  722. )
  723. endif()
  724. file(GLOB _contrib_scripts ${ExternalProjectsContrib_DIR}/*.cmake)
  725. foreach(_contrib_script ${_contrib_scripts})
  726. get_filename_component(_script_name ${_contrib_script} NAME_WE)
  727. list(APPEND CTK_POSSIBLE_DEPENDENCIES ${_script_name})
  728. set(${_script_name}_FILEPATH ${_contrib_script})
  729. endforeach()
  730. endif()
  731. set(CTK_DEPENDENCIES) # This variable will contain the list of required CTK dependencies
  732. include(CMake/ctkBlockCheckDependencies.cmake)
  733. #-----------------------------------------------------------------------------
  734. # Superbuild script
  735. #
  736. if(CTK_SUPERBUILD)
  737. include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  738. return()
  739. endif()
  740. #-----------------------------------------------------------------------------
  741. # Expand variables containing include and library directories for external projects
  742. # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions
  743. foreach(_external_target ${EXTERNAL_TARGETS})
  744. if(${_external_target}_FIND_PACKAGE_CMD)
  745. #message("Calling find_package(${${_external_target}_FIND_PACKAGE_CMD})")
  746. find_package(${${_external_target}_FIND_PACKAGE_CMD} REQUIRED)
  747. endif()
  748. endforeach()
  749. foreach(_external_target ${EXTERNAL_TARGETS})
  750. set(_package_name ${${_external_target}_FIND_PACKAGE_CMD})
  751. if("${_package_name}" STREQUAL "")
  752. set(_package_name ${_external_target})
  753. endif()
  754. if(${_external_target}_INCLUDE_DIRS)
  755. #message("[${_package_name}] Resolving include variables: ${${_external_target}_INCLUDE_DIRS}")
  756. set(_updated_include_dirs)
  757. foreach(_include_variable ${${_external_target}_INCLUDE_DIRS})
  758. set(_expanded_include_variable ${_include_variable})
  759. if(${_include_variable})
  760. #message("[${_package_name}] Expanding [${_include_variable}] into [${${_include_variable}}]")
  761. set(_expanded_include_variable ${${_include_variable}})
  762. endif()
  763. foreach(_include_dir ${_expanded_include_variable})
  764. if(EXISTS ${_include_dir})
  765. #message("[${_package_name}] Appending ${_include_dir}")
  766. list(APPEND _updated_include_dirs ${_include_dir})
  767. else()
  768. message(STATUS "[${_package_name}] Skipping nonexistent include directory or not set variable [${_include_dir}]")
  769. endif()
  770. endforeach()
  771. #message("[${_package_name}] New dirs: ${_updated_include_dirs}")
  772. endforeach()
  773. set(${_external_target}_INCLUDE_DIRS ${_updated_include_dirs})
  774. #message("[${_package_name}] Appended dirs: ${${_external_target}_INCLUDE_DIRS}")
  775. endif()
  776. if(${_external_target}_LIBRARY_DIRS)
  777. #message("[${_package_name}] Resolving library variables: ${${_external_target}_LIBRARY_DIRS}")
  778. set(_updated_library_dirs)
  779. foreach(_library_variable ${${_external_target}_LIBRARY_DIRS})
  780. set(_expanded_library_variable ${_library_variable})
  781. if(${_library_variable})
  782. #message("[${_package_name}] Expanding [${_library_variable}] into [${${_library_variable}}]")
  783. set(_expanded_library_variable ${${_library_variable}})
  784. endif()
  785. foreach(_library_dir ${_expanded_library_variable})
  786. if(EXISTS ${_library_dir})
  787. #message("[${_package_name}] Appending ${_library_dir}")
  788. list(APPEND _updated_library_dirs ${_library_dir})
  789. else()
  790. message(STATUS "[${_package_name}] Skipping nonexistent library directory or not set variable [${_library_dir}]")
  791. endif()
  792. endforeach()
  793. #message("[${_package_name}] New dirs: ${_updated_library_dirs}")
  794. endforeach()
  795. set(${_external_target}_LIBRARY_DIRS ${_updated_library_dirs})
  796. #message("[${_package_name}] Appended dirs: ${${_external_target}_LIBRARY_DIRS}")
  797. endif()
  798. endforeach()
  799. set(CTK_WRAP_PYTHONQT_USE_VTK ${CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK})
  800. #-----------------------------------------------------------------------------
  801. # CTK_SUPERBUILD_BINARY_DIR
  802. # If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
  803. # In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
  804. if(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
  805. set(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
  806. endif()
  807. #-----------------------------------------------------------------------------
  808. # Configure files with settings
  809. #
  810. configure_file(${CTK_SOURCE_DIR}/CMake/UseCTK.cmake.in
  811. ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
  812. set(CTK_CONFIG_H_INCLUDE_DIR ${CTK_BINARY_DIR})
  813. #-----------------------------------------------------------------------------
  814. # Set C/CXX Flags
  815. #
  816. set(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)
  817. set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
  818. #-----------------------------------------------------------------------------
  819. # Set the header template which defines custom export/import macros
  820. # for shared libraries
  821. #
  822. set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")
  823. #-----------------------------------------------------------------------------
  824. # Setup testing environment before Libs are added
  825. #
  826. add_subdirectory(Libs/Testing)
  827. #-----------------------------------------------------------------------------
  828. # Add CTK library subdirectories
  829. #
  830. foreach(lib ${CTK_LIBS})
  831. if(CTK_LIB_${lib})
  832. add_subdirectory(Libs/${lib})
  833. endif()
  834. # Always add the Documentation sub-directory for additional processing
  835. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation/CMakeLists.txt)
  836. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation)
  837. endif()
  838. endforeach()
  839. # Add the CommandLineModules root directory for additional processing
  840. add_subdirectory(Libs/CommandLineModules)
  841. #-----------------------------------------------------------------------------
  842. if(CTK_USE_QTTESTING)
  843. add_subdirectory(Libs/QtTesting)
  844. endif()
  845. #-----------------------------------------------------------------------------
  846. # Add CTK plugin subdirectories
  847. #
  848. foreach(plugin ${CTK_PLUGINS})
  849. if(CTK_PLUGIN_${plugin})
  850. if(${plugin}_SOURCE_DIR)
  851. add_subdirectory(${${plugin}_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Plugins/${plugin})
  852. else()
  853. add_subdirectory(Plugins/${plugin})
  854. endif()
  855. endif()
  856. endforeach()
  857. #-----------------------------------------------------------------------------
  858. # Add CTK application subdirectories
  859. #
  860. foreach(app ${CTK_APPS})
  861. IF (CTK_APP_${app})
  862. add_subdirectory(Applications/${app})
  863. endif()
  864. endforeach()
  865. if(BUILD_TESTING)
  866. add_subdirectory(Applications/Testing)
  867. endif()
  868. #-----------------------------------------------------------------------------
  869. # Add general purpose subdirectories
  870. #
  871. #add_subdirectory(Testing)
  872. #add_subdirectory(Examples)
  873. #-----------------------------------------------------------------------------
  874. # Style Checking configuration
  875. #
  876. include(Utilities/KWStyle/KWStyle.cmake)
  877. #---------------------------------------------------------------------------
  878. # Documentation
  879. #
  880. add_subdirectory( Documentation )
  881. #-----------------------------------------------------------------------------
  882. # The commands in this directory are intended to be executed as
  883. # the end of the whole configuration process, as a "last step".
  884. # This directory is typically the last SUBDIRS in the main CMakeLists.txt.
  885. add_subdirectory(CMake/LastConfigureStep)