CMakeLists.txt 41 KB

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