CMakeLists.txt 38 KB

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