CMakeLists.txt 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  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. if(APPLE)
  23. # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
  24. # we ensure that the bitness will be properly detected.
  25. include(${CMAKE_SOURCE_DIR}/CMake/ctkBlockSetCMakeOSXVariables.cmake)
  26. endif()
  27. #-----------------------------------------------------------------------------
  28. project(CTK)
  29. #-----------------------------------------------------------------------------
  30. #-----------------------------------------------------------------------------
  31. # Library mode: SHARED (default) or STATIC
  32. #
  33. set(CTK_LIBRARY_MODE "SHARED")
  34. option(CTK_BUILD_SHARED_LIBS "Build CTK libraries as shared module." ON)
  35. mark_as_advanced(CTK_BUILD_SHARED_LIBS)
  36. if(NOT CTK_BUILD_SHARED_LIBS)
  37. set(CTK_LIBRARY_MODE "STATIC")
  38. endif()
  39. #-----------------------------------------------------------------------------
  40. # Set a default build type if none was specified
  41. #
  42. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  43. message(STATUS "Setting build type to 'Debug' as none was specified.")
  44. set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  45. mark_as_advanced(CMAKE_BUILD_TYPE)
  46. # Set the possible values of build type for cmake-gui
  47. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
  48. "MinSizeRel" "RelWithDebInfo")
  49. endif()
  50. #-----------------------------------------------------------------------------
  51. # Superbuild Option - Enabled by default
  52. #
  53. option(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  54. mark_as_advanced(CTK_SUPERBUILD)
  55. #-----------------------------------------------------------------------------
  56. # Output directories.
  57. #
  58. foreach(type LIBRARY RUNTIME ARCHIVE)
  59. # Make sure the directory exists
  60. if(DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY
  61. AND NOT EXISTS ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  62. message(FATAL_ERROR "CTK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${CTK_CMAKE_${type}_OUTPUT_DIRECTORY}]")
  63. endif()
  64. if(CTK_SUPERBUILD)
  65. set(output_dir ${CTK_BINARY_DIR}/bin)
  66. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  67. set(CTK_CMAKE_${type}_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
  68. endif()
  69. else()
  70. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  71. set(output_dir ${CTK_BINARY_DIR}/bin)
  72. else()
  73. set(output_dir ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  74. endif()
  75. endif()
  76. set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
  77. if(NOT DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY)
  78. set(CTK_PLUGIN_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
  79. endif()
  80. endforeach()
  81. #-----------------------------------------------------------------------------
  82. # CTK version number. An even minor number corresponds to releases.
  83. #
  84. set(CTK_MAJOR_VERSION 0)
  85. set(CTK_MINOR_VERSION 1)
  86. set(CTK_PATCH_VERSION 0)
  87. set(CTK_VERSION
  88. "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_PATCH_VERSION}")
  89. # Append the library version information to the library target
  90. # properties. A parent project may set its own properties and/or may
  91. # block this.
  92. if(NOT CTK_NO_LIBRARY_VERSION)
  93. set(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
  94. VERSION "${CTK_VERSION}"
  95. SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
  96. )
  97. endif()
  98. #-----------------------------------------------------------------------------
  99. # Install directories, used for install rules.
  100. #
  101. if(NOT CTK_INSTALL_BIN_DIR)
  102. set(CTK_INSTALL_BIN_DIR "bin")
  103. endif()
  104. if(NOT CTK_INSTALL_LIB_DIR)
  105. set(CTK_INSTALL_LIB_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  106. endif()
  107. if(NOT CTK_INSTALL_PLUGIN_DIR)
  108. set(CTK_INSTALL_PLUGIN_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}/plugins")
  109. endif()
  110. if(NOT CTK_INSTALL_CMAKE_DIR)
  111. set(CTK_INSTALL_CMAKE_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}/CMake")
  112. endif()
  113. if(NOT CTK_INSTALL_INCLUDE_DIR)
  114. set(CTK_INSTALL_INCLUDE_DIR "include/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  115. endif()
  116. if(NOT CTK_INSTALL_PLUGIN_INCLUDE_DIR)
  117. set(CTK_INSTALL_PLUGIN_INCLUDE_DIR ${CTK_INSTALL_INCLUDE_DIR})
  118. endif()
  119. if(NOT CTK_INSTALL_QTPLUGIN_DIR)
  120. set(CTK_INSTALL_QTPLUGIN_DIR ${CTK_INSTALL_LIB_DIR})
  121. endif()
  122. if(NOT CTK_INSTALL_DOC_DIR)
  123. set(CTK_INSTALL_DOC_DIR "doc")
  124. endif()
  125. #-----------------------------------------------------------------------------
  126. # Update CMake module path
  127. # Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
  128. #
  129. set(CMAKE_MODULE_PATH
  130. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
  131. "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  132. ${CMAKE_MODULE_PATH})
  133. #-----------------------------------------------------------------------------
  134. # Clear CTK_BASE_INCLUDE_DIRS, CTK_BASE_LIBRARIES and CTK_WRAPPED_LIBRARIES_PYTHONQT
  135. #
  136. set(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
  137. set(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  138. set(CTK_WRAPPED_LIBRARIES_PYTHONQT CACHE INTERNAL "CTK libraries wrapped using PythonQt" FORCE)
  139. # Variable use in CTKConfig.cmake.in
  140. set(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  141. set(${PROJECT_NAME}_PLUGIN_LIBRARIES CACHE INTERNAL "CTK plugins" FORCE)
  142. # Used by CTKGenerateCTKConfig.cmake and also used to reference script from other scripts
  143. set(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
  144. set(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
  145. #-----------------------------------------------------------------------------
  146. # CMake function(s) and macro(s)
  147. #
  148. foreach(file
  149. CMake/ctkListToString.cmake
  150. CMake/ctkMacroParseArguments.cmake
  151. CMake/ctkMacroSetPaths.cmake
  152. CMake/ctkMacroListFilter.cmake
  153. CMake/ctkMacroOptionUtils.cmake
  154. CMake/ctkMacroBuildLib.cmake
  155. CMake/ctkMacroBuildLibWrapper.cmake
  156. CMake/ctkMacroBuildPlugin.cmake
  157. CMake/ctkMacroBuildApp.cmake
  158. CMake/ctkMacroBuildQtPlugin.cmake
  159. CMake/ctkMacroCompilePythonScript.cmake
  160. CMake/ctkMacroGenerateMocs.cmake
  161. CMake/ctkMacroWrapPythonQt.cmake
  162. CMake/ctkMacroSetupQt.cmake
  163. CMake/ctkMacroTargetLibraries.cmake # Import multiple macros
  164. CMake/ctkFunctionExtractOptionNameAndValue.cmake
  165. CMake/ctkMacroValidateBuildOptions.cmake
  166. CMake/ctkMacroAddCtkLibraryOptions.cmake
  167. CMake/ctkFunctionGenerateDGraphInput.cmake
  168. CMake/ctkFunctionGenerateProjectXml.cmake
  169. CMake/ctkFunctionGeneratePluginManifest.cmake
  170. CMake/ctkMacroGeneratePluginResourceFile.cmake
  171. CMake/ctkFunctionAddPluginRepo.cmake
  172. CMake/ctkFunctionCheckCompilerFlags.cmake
  173. CMake/ctkFunctionCheckoutRepo.cmake
  174. CMake/ctkFunctionGetIncludeDirs.cmake
  175. CMake/ctkFunctionGetLibraryDirs.cmake
  176. CMake/ctkFunctionGetGccVersion.cmake
  177. CMake/ctkFunctionGetCompilerVisibilityFlags.cmake
  178. CMake/ctkFunctionCompileSnippets.cmake
  179. )
  180. include(${file})
  181. install(FILES ${file} DESTINATION ${CTK_INSTALL_CMAKE_DIR} COMPONENT Development)
  182. endforeach()
  183. foreach(file
  184. Libs/ctkExport.h.in
  185. CMake/ctkLinkerAsNeededFlagCheck.cmake
  186. )
  187. install(FILES ${file} DESTINATION ${CTK_INSTALL_CMAKE_DIR} COMPONENT Development)
  188. endforeach()
  189. install(FILES
  190. CMake/ctkLinkerAsNeededFlagCheck/CMakeLists.txt
  191. CMake/ctkLinkerAsNeededFlagCheck/A.cpp
  192. CMake/ctkLinkerAsNeededFlagCheck/B.cpp
  193. CMake/ctkLinkerAsNeededFlagCheck/C.cpp
  194. DESTINATION ${CTK_INSTALL_CMAKE_DIR}/ctkLinkerAsNeededFlagCheck
  195. COMPONENT Development
  196. )
  197. #-----------------------------------------------------------------------------
  198. # Testing
  199. #
  200. include(CTest)
  201. mark_as_advanced(BUILD_TESTING)
  202. if(BUILD_TESTING)
  203. set(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  204. mark_as_advanced(TCL_TCLSH DART_ROOT)
  205. include(CMake/ctkMacroSimpleTest.cmake)
  206. include(CMake/ctkMacroSimpleTestWithData.cmake)
  207. # Setup file for setting custom ctest vars
  208. configure_file(
  209. CMake/CTestCustom.cmake.in
  210. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  211. @ONLY
  212. )
  213. # Configuration for the CMake-generated test driver
  214. set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  215. set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  216. try
  217. {")
  218. set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  219. catch( std::exception & excp )
  220. {
  221. fprintf(stderr,\"%s\\n\",excp.what());
  222. return EXIT_FAILURE;
  223. }
  224. catch( ... )
  225. {
  226. printf(\"Exception caught in the test driver\\n\");
  227. return EXIT_FAILURE;
  228. }
  229. ")
  230. endif()
  231. #-----------------------------------------------------------------------------
  232. # QtTesting
  233. #
  234. option(CTK_USE_QTTESTING "Enable/Disable QtTesting" OFF)
  235. mark_as_advanced(CTK_USE_QTTESTING)
  236. #-----------------------------------------------------------------------------
  237. # Coverage
  238. #
  239. option(WITH_COVERAGE "Enable/Disable coverage" OFF)
  240. mark_as_advanced(WITH_COVERAGE)
  241. #-----------------------------------------------------------------------------
  242. # Documentation
  243. #
  244. option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
  245. mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)
  246. set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  247. CACHE PATH "Where documentation archives should be stored")
  248. mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
  249. #-----------------------------------------------------------------------------
  250. # Additional CXX/C Flags
  251. #
  252. set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
  253. mark_as_advanced(ADDITIONAL_C_FLAGS)
  254. set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
  255. mark_as_advanced(ADDITIONAL_CXX_FLAGS)
  256. #-----------------------------------------------------------------------------
  257. # Set symbol visibility Flags
  258. #
  259. ctkFunctionGetCompilerVisibilityFlags(VISIBILITY_CXX_FLAGS)
  260. #-----------------------------------------------------------------------------
  261. # Set coverage Flags
  262. #
  263. if(WITH_COVERAGE)
  264. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  265. set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")
  266. set(COVERAGE_CXX_FLAGS ${coverage_flags})
  267. set(COVERAGE_C_FLAGS ${coverage_flags})
  268. endif()
  269. endif()
  270. #-----------------------------------------------------------------------------
  271. # CTK C/CXX Flags
  272. #
  273. set(CTK_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
  274. set(CTK_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
  275. if(CMAKE_COMPILER_IS_GNUCXX)
  276. set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings")
  277. if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  278. set(cflags "${cflags} -D_FORTIFY_SOURCE=2")
  279. endif()
  280. ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)
  281. ctkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags)
  282. ctkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
  283. # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so
  284. # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag.
  285. # Doing so should allow to build package made for distribution using older linux distro.
  286. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0"))
  287. ctkFunctionCheckCompilerFlags("-fstack-protector-all" cflags)
  288. endif()
  289. if(MINGW)
  290. # suppress warnings about auto imported symbols
  291. set(CTK_CXX_FLAGS "-Wl,--enable-auto-import ${CTK_CXX_FLAGS}")
  292. endif()
  293. set(CTK_C_FLAGS "${cflags} ${CTK_C_FLAGS}")
  294. set(CTK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${CTK_CXX_FLAGS}")
  295. endif()
  296. if(MSVC)
  297. set(msvc_suppressed_warnings
  298. "/wd4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  299. )
  300. set(CTK_CXX_FLAGS "${CTK_CXX_FLAGS} ${msvc_suppressed_warnings}")
  301. endif()
  302. #-----------------------------------------------------------------------------
  303. # Check if the linker will resolve symbols of underlinked libraries
  304. #
  305. if(UNIX AND NOT APPLE)
  306. include(ctkLinkerAsNeededFlagCheck)
  307. if(CTK_LINKER_NO_AS_NEEDED_FLAG_REQUIRED)
  308. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed"
  309. CACHE STRING "Flags used by the linker"
  310. FORCE)
  311. endif()
  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/XMLChecker
  431. "Build the Command Line Module back-end for checking XML" OFF)
  432. ctk_lib_option(CommandLineModules/Backend/LocalProcess
  433. "Build the Command Line Module back-end for local processes" OFF)
  434. ctk_lib_option(CommandLineModules/Backend/FunctionPointer
  435. "Build the Command Line Module back-end for function pointers" OFF)
  436. #ctk_lib_option(Visualization/XIP
  437. # "Build the XIP library" OFF)
  438. # Save the set of enabled libs in a cache file
  439. set(_enabled_libs)
  440. foreach(_lib ${CTK_LIBS})
  441. if(CTK_LIB_${_lib})
  442. list(APPEND _enabled_libs ${_lib})
  443. endif()
  444. endforeach()
  445. set(CTK_ENABLED_LIBS ${_enabled_libs} CACHE INTERNAL "" FORCE)
  446. #-----------------------------------------------------------------------------
  447. # CTK Applications - Use ON or OFF to indicate if the application should be built by default
  448. #
  449. ctk_app_option(ctkDICOM
  450. "Build the DICOM example application" OFF
  451. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  452. ctk_app_option(ctkDICOM2
  453. "Build the new DICOM example application (experimental)" OFF
  454. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  455. ctk_app_option(ctkDICOMIndexer
  456. "Build the DICOM example application" OFF
  457. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  458. ctk_app_option(ctkDICOMDemoSCU
  459. "Build the DICOM example application" OFF
  460. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  461. ctk_app_option(ctkDICOMQuery
  462. "Build the DICOM example application" OFF
  463. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  464. ctk_app_option(ctkDICOMRetrieve
  465. "Build the DICOM example application" OFF
  466. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  467. ctk_app_option(ctkDICOMQueryRetrieve
  468. "Build the DICOM example application" OFF
  469. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  470. ctk_app_option(ctkDICOMHost
  471. "Build the DICOM application host example application" OFF
  472. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  473. ctk_app_option(ctkExampleHost
  474. "Build the DICOM example application" OFF
  475. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  476. ctk_app_option(ctkExampleHostedApp
  477. "Build the DICOM example application" OFF
  478. CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
  479. ctk_app_option(ctkEventBusDemo
  480. "Build the DICOM example application" OFF
  481. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  482. ctk_app_option(ctkCommandLineModuleExplorer
  483. "Build the Command Line Module Explorer" OFF
  484. CTK_BUILD_EXAMPLES)
  485. # We use the CTKWidgets library together with the Qt Designer plug-in
  486. # in ctkCommandLineModuleExplorer, so enabling the options here.
  487. # (We do not need to link them into the executable, hence no entries
  488. # in target_libraries.cmake)
  489. if(CTK_APP_ctkCommandLineModuleExplorer)
  490. foreach(_option CTK_BUILD_QTDESIGNER_PLUGINS)
  491. if(NOT ${_option})
  492. get_property(_docstring CACHE ${_option} PROPERTY HELPSTRING)
  493. set(${_option} ON CACHE BOOL "${_docstring}" FORCE)
  494. message("Enabling option [${_option}] required by [ctkCommandLineModuleExplorer]")
  495. endif()
  496. endforeach()
  497. endif()
  498. ctk_app_option(ctkPluginBrowser
  499. "Build the DICOM example application" OFF
  500. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  501. ctk_app_option(ctkPluginGenerator
  502. "Build the DICOM example application" OFF
  503. CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
  504. ctk_app_option(ctkDICOMObjectViewer
  505. "Build the DICOM example application" OFF
  506. CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
  507. ctk_app_option(ctkSimplePythonShell
  508. "Build the DICOM example application" OFF
  509. CTK_ENABLE_Python_Wrapping AND CTK_BUILD_EXAMPLES)
  510. if(CTK_USE_QTTESTING)
  511. ctk_app_option(ctkQtTesting
  512. "Build the ctkQtTesting example application" OFF
  513. CTK_BUILD_EXAMPLES)
  514. endif()
  515. # Save the set of enabled apps in a cache file
  516. set(_enabled_apps)
  517. foreach(_app ${CTK_APPS})
  518. if(CTK_APP_${_app})
  519. list(APPEND _enabled_apps ${_app})
  520. endif()
  521. endforeach()
  522. set(CTK_ENABLED_APPS ${_enabled_apps} CACHE INTERNAL "" FORCE)
  523. #-----------------------------------------------------------------------------
  524. # CTK Plugins - none of them is build by default
  525. #
  526. # Plugins in the list below are not build by default
  527. set(plugin_list
  528. # Optional plug-ins implementings interfaces in PluginFramework/service/
  529. org.commontk.configadmin
  530. org.commontk.eventadmin
  531. org.commontk.log
  532. org.commontk.log4qt
  533. org.commontk.metatype
  534. )
  535. foreach(_plugin ${plugin_list})
  536. ctk_plugin_option(${_plugin} "Build the ${_plugin} plugin." OFF)
  537. endforeach()
  538. # Plug-ins related to the PluginGenerator application
  539. ctk_plugin_option(org.commontk.plugingenerator.core "Build the org.commontk.plugingenerator.core plugin." OFF)
  540. ctk_plugin_option(org.commontk.plugingenerator.ui
  541. "Build the org.commontk.plugingenerator.ui plugin." OFF
  542. CTK_APP_ctkPluginGenerator)
  543. # Plug-ins related to DICOM WG23 (Application Hosting)
  544. ctk_plugin_option(org.commontk.dah.core "Build the org.commontk.dah.core plugin." OFF)
  545. ctk_plugin_option(org.commontk.dah.hostedapp "Build the org.commontk.dah.hostedapp plugin." OFF
  546. CTK_ENABLE_DICOMApplicationHosting)
  547. ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin." OFF
  548. CTK_ENABLE_DICOMApplicationHosting)
  549. ctk_plugin_option(org.commontk.dah.exampleapp
  550. "Build the org.commontk.dah.exampleapp plugin." OFF
  551. CTK_APP_ctkExampleHostedApp)
  552. ctk_plugin_option(org.commontk.dah.cmdlinemoduleapp
  553. "Build the org.commontk.dah.cmdlinemoduleapp plugin." OFF
  554. CTK_APP_ctkCommandLineModuleApp)
  555. ctk_plugin_option(org.commontk.dah.examplehost
  556. "Build the org.commontk.dah.examplehost plugin." OFF
  557. CTK_APP_ctkExampleHost)
  558. # Plug-ins related to the EventBus demo application
  559. ctk_plugin_option(org.commontk.eventbus
  560. "Build the org.commontk.eventbus plugin." OFF
  561. CTK_APP_ctkEventBusDemo)
  562. # Add the PluginsContrib repo to the build system
  563. option(CTK_USE_CONTRIBUTED_PLUGINS OFF "Use CTK plug-ins from the PluginsContrib repository")
  564. mark_as_advanced(CTK_USE_CONTRIBUTED_PLUGINS)
  565. if(CTK_USE_CONTRIBUTED_PLUGINS)
  566. ctkFunctionAddPluginRepo(NAME PluginsContrib
  567. GIT_URL github.com/commontk/PluginsContrib.git
  568. GIT_TAG 7fc37f400c
  569. )
  570. endif()
  571. #-----------------------------------------------------------------------------
  572. # Generate target_directories list - List of directory corresponding to the different
  573. # libraries, plugins and applications associated with the corresponding option name.
  574. #
  575. # The following FOREACH loops are used to:
  576. # 1) Update either CTK_LIBS_SUBDIRS, CTK_PLUGINS_SUBDIRS or CTK_APPS_SUBDIRS variables
  577. #
  578. # For CTK libraries, if the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists,
  579. # in addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
  580. # will also be available in CMake configure menu:
  581. # CTK_LIB_<DIR>/<LIBNAME>_OPT1 (set to OFF)
  582. # CTK_LIB_<DIR>/<LIBNAME>_OPT2 (set to ON)
  583. #
  584. # The file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake should look like:
  585. #
  586. # set(ctk_library_options
  587. # OPT1:OFF
  588. # OPT2:ON
  589. # )
  590. # Create list of directories corresponding to the enabled targets
  591. set(target_directories)
  592. set(ctk_lib_options_list) # This list will be updated in ctkMacroAddCtkLibraryOptions
  593. foreach(lib ${CTK_LIBS})
  594. if(CTK_LIB_${lib})
  595. ctkMacroAddCtkLibraryOptions(${lib})
  596. endif()
  597. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^CTK_LIB_${lib}")
  598. endforeach()
  599. foreach(plugin ${CTK_PLUGINS})
  600. if(${plugin}_SOURCE_DIR)
  601. list(APPEND target_directories "${${plugin}_SOURCE_DIR}^^CTK_PLUGIN_${plugin}")
  602. else()
  603. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^CTK_PLUGIN_${plugin}")
  604. endif()
  605. endforeach()
  606. foreach(app ${CTK_APPS})
  607. list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^CTK_APP_${app}")
  608. endforeach()
  609. #message(STATUS target_directories:${target_directories})
  610. #-----------------------------------------------------------------------------
  611. # Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
  612. # topological order.
  613. try_compile(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
  614. DGraph
  615. CMAKE_FLAGS
  616. -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  617. -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
  618. -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}
  619. -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
  620. OUTPUT_VARIABLE output)
  621. if(NOT RESULT_VAR)
  622. message(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
  623. endif()
  624. find_program(DGraph_EXECUTABLE DGraph
  625. "${CTK_BINARY_DIR}/Utilities/DGraph/"
  626. "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
  627. "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
  628. "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
  629. mark_as_advanced(DGraph_EXECUTABLE)
  630. #-----------------------------------------------------------------------------
  631. # Let's make sure the enabled/disabled libraries, plugins or applications are coherent
  632. #
  633. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}")
  634. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_EXTERNALS)
  635. ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
  636. #-----------------------------------------------------------------------------
  637. # CTK Python wrapping
  638. # Enable CTK_LIB_Scripting/Python/Core if either CTK_ENABLE_Python_Wrapping OR CTK_WRAP_PYTHONQT_FULL
  639. #
  640. set(CTK_WRAP_PYTHONQT_LIGHT ${CTK_ENABLE_Python_Wrapping})
  641. option(CTK_WRAP_PYTHONQT_FULL "Experimental - Wrap CTK classes using Qt meta-object system into Python language" OFF)
  642. mark_as_advanced(CTK_WRAP_PYTHONQT_FULL)
  643. if(CTK_WRAP_PYTHONQT_FULL AND CTK_WRAP_PYTHONQT_LIGHT)
  644. message(FATAL_ERROR "CTK_ENABLE_Python_Wrapping AND CTK_WRAP_PYTHONQT_FULL options are mutually exclusive. Please enable only one !")
  645. endif()
  646. set(logical_expr CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL)
  647. if((${logical_expr}) AND NOT CTK_LIB_Scripting/Python/Core)
  648. set(CTK_LIB_Scripting/Python/Core ON CACHE BOOL "Build the Python Core library" FORCE)
  649. set(enabling_msg)
  650. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  651. message("Enabling [CTK_LIB_Scripting/Python/Core] because of [${enabling_msg}] evaluates to True")
  652. endif()
  653. set(logical_expr CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  654. if(${logical_expr} AND NOT CTK_LIB_Visualization/VTK/Core)
  655. set(CTK_LIB_Visualization/VTK/Core ON CACHE BOOL "Build the VTK Core library" FORCE)
  656. set(enabling_msg)
  657. ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")
  658. message("Enabling [CTK_LIB_Visualization/VTK/Core] because of [${enabling_msg}] evaluates to True")
  659. endif()
  660. # Check if dependencies are satisfied
  661. if(CTK_LIB_Scripting/Python/Core)
  662. find_package(PythonInterp)
  663. if(NOT PYTHONINTERP_FOUND)
  664. message(FATAL_ERROR "PYTHON_EXECUTABLE variable should be set to build CTK_LIB_Scripting/Python")
  665. endif()
  666. find_package(PythonLibs)
  667. if(NOT PYTHONLIBS_FOUND)
  668. message(FATAL_ERROR "PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS should be set to build CTK_LIB_Scripting/Python")
  669. endif()
  670. endif()
  671. #-----------------------------------------------------------------------------
  672. # DGraph
  673. #
  674. # Generate DGraph input file expected by DGraph
  675. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_OPTION)
  676. # Obtain list of target ordered topologically
  677. ctkMacroSetPaths("${QT_INSTALLED_LIBRARY_DIR}")
  678. execute_process(
  679. COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
  680. WORKING_DIRECTORY ${CTK_BINARY_DIR}
  681. RESULT_VARIABLE RESULT_VAR
  682. OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS_OUTPUT
  683. ERROR_VARIABLE error
  684. OUTPUT_STRIP_TRAILING_WHITESPACE
  685. )
  686. if(RESULT_VAR)
  687. message(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
  688. endif()
  689. # Convert 'CTEST_PROJECT_SUBPROJECTS_OUTPUT' to a list
  690. string(REPLACE " " "\\;" CTEST_PROJECT_SUBPROJECTS "${CTEST_PROJECT_SUBPROJECTS_OUTPUT}")
  691. set(CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS})
  692. # If the list of subproject is empty, let's at least build CTKCore
  693. list(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
  694. IF (subproject_count EQUAL 0)
  695. set(CTEST_PROJECT_SUBPROJECTS CTKCore)
  696. endif()
  697. # Configure CTestConfigSubProject.cmake that could be used by CTest scripts
  698. configure_file(${CTK_SOURCE_DIR}/CMake/CTestConfigSubProject.cmake.in
  699. ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
  700. #-----------------------------------------------------------------------------
  701. # Project.xml
  702. #
  703. # Generate Project.xml file expected by the CTest driver script
  704. ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
  705. #-----------------------------------------------------------------------------
  706. # CTK dependencies - Projects should be TOPOLOGICALLY ordered
  707. #-----------------------------------------------------------------------------
  708. set(CTK_DEPENDENCIES
  709. Log4Qt
  710. VTK
  711. PythonQt
  712. DCMTK
  713. ZMQ
  714. QtSOAP
  715. qxmlrpc
  716. OpenIGTLink
  717. XIP
  718. ITK
  719. )
  720. if(BUILD_TESTING)
  721. list(APPEND CTK_DEPENDENCIES CTKData)
  722. endif()
  723. if(CTK_USE_KWSTYLE)
  724. list(APPEND CTK_DEPENDENCIES KWStyle)
  725. endif()
  726. if(CTK_USE_QTTESTING)
  727. list(APPEND CTK_DEPENDENCIES QtTesting)
  728. endif()
  729. if(CTK_WRAP_PYTHONQT_FULL)
  730. list(APPEND CTK_DEPENDENCIES PythonQtGenerator)
  731. endif()
  732. #-----------------------------------------------------------------------------
  733. # Check out the ExternalProjectsContrib repository
  734. if(CTK_USE_CONTRIBUTED_PLUGINS)
  735. if(CTK_SUPERBUILD)
  736. ctkFunctionCheckoutRepo(
  737. NAME ExternalProjectsContrib
  738. GIT_URL github.com/commontk/ExternalProjectsContrib.git
  739. GIT_TAG 80ce3d5
  740. )
  741. endif()
  742. file(GLOB _contrib_scripts ${ExternalProjectsContrib_DIR}/*.cmake)
  743. foreach(_contrib_script ${_contrib_scripts})
  744. get_filename_component(_script_name ${_contrib_script} NAME_WE)
  745. list(APPEND CTK_DEPENDENCIES ${_script_name})
  746. set(${_script_name}_FILEPATH ${_contrib_script})
  747. endforeach()
  748. endif()
  749. include(CMake/ctkBlockCheckDependencies.cmake)
  750. #-----------------------------------------------------------------------------
  751. # Superbuild script
  752. #
  753. if(CTK_SUPERBUILD)
  754. include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  755. return()
  756. endif()
  757. if(BUILD_TESTING)
  758. add_subdirectory(CMake/Testing)
  759. endif()
  760. #-----------------------------------------------------------------------------
  761. # Expand variables containing include and library directories for external projects
  762. # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions
  763. foreach(_external_target ${EXTERNAL_TARGETS})
  764. if(${_external_target}_FIND_PACKAGE_CMD)
  765. #message("Calling find_package(${${_external_target}_FIND_PACKAGE_CMD})")
  766. find_package(${${_external_target}_FIND_PACKAGE_CMD} REQUIRED)
  767. endif()
  768. endforeach()
  769. foreach(_external_target ${EXTERNAL_TARGETS})
  770. set(_package_name ${${_external_target}_FIND_PACKAGE_CMD})
  771. if("${_package_name}" STREQUAL "")
  772. set(_package_name ${_external_target})
  773. endif()
  774. if(${_external_target}_INCLUDE_DIRS)
  775. #message("[${_package_name}] Resolving include variables: ${${_external_target}_INCLUDE_DIRS}")
  776. set(_updated_include_dirs)
  777. foreach(_include_variable ${${_external_target}_INCLUDE_DIRS})
  778. set(_expanded_include_variable ${_include_variable})
  779. if(${_include_variable})
  780. #message("[${_package_name}] Expanding [${_include_variable}] into [${${_include_variable}}]")
  781. set(_expanded_include_variable ${${_include_variable}})
  782. endif()
  783. foreach(_include_dir ${_expanded_include_variable})
  784. if(EXISTS ${_include_dir})
  785. #message("[${_package_name}] Appending ${_include_dir}")
  786. list(APPEND _updated_include_dirs ${_include_dir})
  787. else()
  788. message(STATUS "[${_package_name}] Skipping nonexistent include directory or not set variable [${_include_dir}]")
  789. endif()
  790. endforeach()
  791. #message("[${_package_name}] New dirs: ${_updated_include_dirs}")
  792. endforeach()
  793. set(${_external_target}_INCLUDE_DIRS ${_updated_include_dirs})
  794. #message("[${_package_name}] Appended dirs: ${${_external_target}_INCLUDE_DIRS}")
  795. endif()
  796. if(${_external_target}_LIBRARY_DIRS)
  797. #message("[${_package_name}] Resolving library variables: ${${_external_target}_LIBRARY_DIRS}")
  798. set(_updated_library_dirs)
  799. foreach(_library_variable ${${_external_target}_LIBRARY_DIRS})
  800. set(_expanded_library_variable ${_library_variable})
  801. if(${_library_variable})
  802. #message("[${_package_name}] Expanding [${_library_variable}] into [${${_library_variable}}]")
  803. set(_expanded_library_variable ${${_library_variable}})
  804. endif()
  805. foreach(_library_dir ${_expanded_library_variable})
  806. if(EXISTS ${_library_dir})
  807. #message("[${_package_name}] Appending ${_library_dir}")
  808. list(APPEND _updated_library_dirs ${_library_dir})
  809. else()
  810. message(STATUS "[${_package_name}] Skipping nonexistent library directory or not set variable [${_library_dir}]")
  811. endif()
  812. endforeach()
  813. #message("[${_package_name}] New dirs: ${_updated_library_dirs}")
  814. endforeach()
  815. set(${_external_target}_LIBRARY_DIRS ${_updated_library_dirs})
  816. #message("[${_package_name}] Appended dirs: ${${_external_target}_LIBRARY_DIRS}")
  817. endif()
  818. endforeach()
  819. set(CTK_WRAP_PYTHONQT_USE_VTK ${CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK})
  820. #-----------------------------------------------------------------------------
  821. # CTK_SUPERBUILD_BINARY_DIR
  822. # If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
  823. # In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
  824. if(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
  825. set(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
  826. endif()
  827. #-----------------------------------------------------------------------------
  828. # Configure files with settings
  829. #
  830. configure_file(${CTK_SOURCE_DIR}/CMake/UseCTK.cmake.in
  831. ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY)
  832. install(
  833. FILES ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake
  834. DESTINATION ${CTK_INSTALL_CMAKE_DIR} COMPONENT Development
  835. )
  836. set(CTK_CONFIG_H_INCLUDE_DIR ${CTK_BINARY_DIR})
  837. #-----------------------------------------------------------------------------
  838. # Set C/CXX Flags
  839. #
  840. set(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)
  841. set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
  842. #-----------------------------------------------------------------------------
  843. # Set the header template which defines custom export/import macros
  844. # for shared libraries
  845. #
  846. set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")
  847. #-----------------------------------------------------------------------------
  848. # Setup testing environment before Libs are added
  849. #
  850. add_subdirectory(Libs/Testing)
  851. #-----------------------------------------------------------------------------
  852. # Add CTK library subdirectories
  853. #
  854. foreach(lib ${CTK_LIBS})
  855. if(CTK_LIB_${lib})
  856. add_subdirectory(Libs/${lib})
  857. endif()
  858. # Always add the Documentation sub-directory for additional processing
  859. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation/CMakeLists.txt)
  860. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation)
  861. endif()
  862. endforeach()
  863. # Add the CommandLineModules root directory for additional processing
  864. add_subdirectory(Libs/CommandLineModules)
  865. #-----------------------------------------------------------------------------
  866. if(CTK_USE_QTTESTING)
  867. add_subdirectory(Libs/QtTesting)
  868. endif()
  869. #-----------------------------------------------------------------------------
  870. # Add CTK plugin subdirectories
  871. #
  872. foreach(plugin ${CTK_PLUGINS})
  873. if(CTK_PLUGIN_${plugin})
  874. if(${plugin}_SOURCE_DIR)
  875. add_subdirectory(${${plugin}_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Plugins/${plugin})
  876. else()
  877. add_subdirectory(Plugins/${plugin})
  878. endif()
  879. endif()
  880. endforeach()
  881. #-----------------------------------------------------------------------------
  882. # Add CTK application subdirectories
  883. #
  884. foreach(app ${CTK_APPS})
  885. IF (CTK_APP_${app})
  886. add_subdirectory(Applications/${app})
  887. endif()
  888. endforeach()
  889. if(BUILD_TESTING)
  890. add_subdirectory(Applications/Testing)
  891. endif()
  892. #-----------------------------------------------------------------------------
  893. # Add general purpose subdirectories
  894. #
  895. #add_subdirectory(Testing)
  896. #add_subdirectory(Examples)
  897. #-----------------------------------------------------------------------------
  898. # Style Checking configuration
  899. #
  900. include(Utilities/KWStyle/KWStyle.cmake)
  901. #---------------------------------------------------------------------------
  902. # Documentation
  903. #
  904. add_subdirectory( Documentation )
  905. #-----------------------------------------------------------------------------
  906. # The commands in this directory are intended to be executed as
  907. # the end of the whole configuration process, as a "last step".
  908. # This directory is typically the last SUBDIRS in the main CMakeLists.txt.
  909. add_subdirectory(CMake/LastConfigureStep)