CMakeLists.txt 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) Kitware Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0.txt
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. ###########################################################################
  20. cmake_minimum_required(VERSION 2.8.4)
  21. #-----------------------------------------------------------------------------
  22. # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
  23. #
  24. set(project_policies
  25. CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
  26. CMP0002 # NEW: Logical target names must be globally unique.
  27. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
  28. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
  29. CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
  30. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
  31. CMP0007 # NEW: List command no longer ignores empty elements.
  32. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
  33. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
  34. CMP0010 # NEW: Bad variable reference syntax is an error.
  35. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
  36. CMP0012 # NEW: if() recognizes numbers and boolean constants.
  37. CMP0013 # NEW: Duplicate binary directories are not allowed.
  38. CMP0014 # NEW: Input directories must have CMakeLists.txt
  39. )
  40. foreach(policy ${project_policies})
  41. if(POLICY ${policy})
  42. cmake_policy(SET ${policy} NEW)
  43. endif()
  44. endforeach()
  45. #-----------------------------------------------------------------------------
  46. if(APPLE)
  47. # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
  48. # we ensure that the bitness will be properly detected.
  49. include(${CMAKE_SOURCE_DIR}/CMake/ctkBlockSetCMakeOSXVariables.cmake)
  50. endif()
  51. #-----------------------------------------------------------------------------
  52. project(CTK)
  53. #-----------------------------------------------------------------------------
  54. #-----------------------------------------------------------------------------
  55. # Library mode: SHARED (default) or STATIC
  56. #
  57. set(CTK_LIBRARY_MODE "SHARED")
  58. option(CTK_BUILD_SHARED_LIBS "Build CTK libraries as shared module." ON)
  59. mark_as_advanced(CTK_BUILD_SHARED_LIBS)
  60. if(NOT CTK_BUILD_SHARED_LIBS)
  61. set(CTK_LIBRARY_MODE "STATIC")
  62. endif()
  63. #-----------------------------------------------------------------------------
  64. # Set a default build type if none was specified
  65. #
  66. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  67. message(STATUS "Setting build type to 'Debug' as none was specified.")
  68. set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  69. mark_as_advanced(CMAKE_BUILD_TYPE)
  70. # Set the possible values of build type for cmake-gui
  71. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
  72. "MinSizeRel" "RelWithDebInfo")
  73. endif()
  74. #-----------------------------------------------------------------------------
  75. # Superbuild Option - Enabled by default
  76. #
  77. option(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  78. mark_as_advanced(CTK_SUPERBUILD)
  79. #-----------------------------------------------------------------------------
  80. # Output directories.
  81. #
  82. foreach(type LIBRARY RUNTIME ARCHIVE)
  83. # Make sure the directory exists
  84. if(DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY
  85. AND NOT EXISTS ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  86. message(FATAL_ERROR "CTK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${CTK_CMAKE_${type}_OUTPUT_DIRECTORY}]")
  87. endif()
  88. if(CTK_SUPERBUILD)
  89. set(output_dir ${CTK_BINARY_DIR}/bin)
  90. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  91. set(CTK_CMAKE_${type}_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
  92. endif()
  93. else()
  94. if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  95. set(output_dir ${CTK_BINARY_DIR}/bin)
  96. else()
  97. set(output_dir ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  98. endif()
  99. endif()
  100. set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
  101. if(NOT DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY)
  102. set(CTK_PLUGIN_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
  103. endif()
  104. endforeach()
  105. #-----------------------------------------------------------------------------
  106. # CTK version number. An even minor number corresponds to releases.
  107. #
  108. set(CTK_MAJOR_VERSION 0)
  109. set(CTK_MINOR_VERSION 1)
  110. set(CTK_PATCH_VERSION 0)
  111. set(CTK_VERSION
  112. "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_PATCH_VERSION}")
  113. # Append the library version information to the library target
  114. # properties. A parent project may set its own properties and/or may
  115. # block this.
  116. if(NOT CTK_NO_LIBRARY_VERSION)
  117. set(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
  118. VERSION "${CTK_VERSION}"
  119. SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
  120. )
  121. endif()
  122. #-----------------------------------------------------------------------------
  123. # Install directories, used for install rules.
  124. #
  125. if(NOT CTK_INSTALL_BIN_DIR)
  126. set(CTK_INSTALL_BIN_DIR "bin")
  127. endif()
  128. if(NOT CTK_INSTALL_LIB_DIR)
  129. set(CTK_INSTALL_LIB_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  130. endif()
  131. if(NOT CTK_INSTALL_INCLUDE_DIR)
  132. set(CTK_INSTALL_INCLUDE_DIR "include/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  133. endif()
  134. if(NOT CTK_INSTALL_DOC_DIR)
  135. set(CTK_INSTALL_DOC_DIR "doc")
  136. endif()
  137. #-----------------------------------------------------------------------------
  138. # Update CMake module path
  139. # Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
  140. #
  141. set(CMAKE_MODULE_PATH
  142. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
  143. "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  144. ${CMAKE_MODULE_PATH})
  145. #-----------------------------------------------------------------------------
  146. # Clear CTK_BASE_INCLUDE_DIRS, CTK_BASE_LIBRARIES and CTK_WRAPPED_LIBRARIES_PYTHONQT
  147. #
  148. set(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
  149. set(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  150. set(CTK_WRAPPED_LIBRARIES_PYTHONQT CACHE INTERNAL "CTK libraries wrapped using PythonQt" FORCE)
  151. # Variable use in CTKConfig.cmake.in
  152. set(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  153. set(${PROJECT_NAME}_PLUGIN_LIBRARIES CACHE INTERNAL "CTK plugins" FORCE)
  154. # Used by CTKGenerateCTKConfig.cmake and also used to reference script from other scripts
  155. set(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
  156. set(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
  157. #-----------------------------------------------------------------------------
  158. # CMake function(s) and macro(s)
  159. #
  160. include(CMake/ctkMacroParseArguments.cmake)
  161. include(CMake/ctkMacroSetPaths.cmake)
  162. include(CMake/ctkMacroListFilter.cmake)
  163. include(CMake/ctkMacroOptionUtils.cmake)
  164. include(CMake/ctkMacroBuildLib.cmake)
  165. include(CMake/ctkMacroBuildLibWrapper.cmake)
  166. include(CMake/ctkMacroBuildPlugin.cmake)
  167. include(CMake/ctkMacroBuildApp.cmake)
  168. include(CMake/ctkMacroBuildQtPlugin.cmake)
  169. include(CMake/ctkMacroCompilePythonScript.cmake)
  170. include(CMake/ctkMacroGenerateMocs.cmake)
  171. include(CMake/ctkMacroWrapPythonQt.cmake)
  172. include(CMake/ctkMacroSetupQt.cmake)
  173. include(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macros
  174. include(CMake/ctkFunctionExtractOptionNameAndValue.cmake)
  175. include(CMake/ctkMacroValidateBuildOptions.cmake)
  176. include(CMake/ctkMacroAddCtkLibraryOptions.cmake)
  177. include(CMake/ctkFunctionGenerateDGraphInput.cmake)
  178. include(CMake/ctkFunctionGenerateProjectXml.cmake)
  179. include(CMake/ctkFunctionGeneratePluginManifest.cmake)
  180. include(CMake/ctkMacroGeneratePluginResourceFile.cmake)
  181. include(CMake/ctkFunctionAddPluginRepo.cmake)
  182. include(CMake/ctkFunctionCheckCompilerFlags.cmake)
  183. include(CMake/ctkFunctionCheckoutRepo.cmake)
  184. include(CMake/ctkFunctionGetIncludeDirs.cmake)
  185. include(CMake/ctkFunctionGetLibraryDirs.cmake)
  186. include(CMake/ctkFunctionGetGccVersion.cmake)
  187. include(CMake/ctkFunctionGetCompilerVisibilityFlags.cmake)
  188. include(CMake/ctkFunctionCompileSnippets.cmake)
  189. #-----------------------------------------------------------------------------
  190. # Testing
  191. #
  192. include(CTest)
  193. mark_as_advanced(BUILD_TESTING)
  194. if(BUILD_TESTING)
  195. set(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  196. mark_as_advanced(TCL_TCLSH DART_ROOT)
  197. include(CMake/ctkMacroSimpleTest.cmake)
  198. include(CMake/ctkMacroSimpleTestWithData.cmake)
  199. # Setup file for setting custom ctest vars
  200. configure_file(
  201. CMake/CTestCustom.cmake.in
  202. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  203. @ONLY
  204. )
  205. # Configuration for the CMake-generated test driver
  206. set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  207. set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  208. try
  209. {")
  210. set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  211. catch( std::exception & excp )
  212. {
  213. fprintf(stderr,\"%s\\n\",excp.what());
  214. return EXIT_FAILURE;
  215. }
  216. catch( ... )
  217. {
  218. printf(\"Exception caught in the test driver\\n\");
  219. return EXIT_FAILURE;
  220. }
  221. ")
  222. endif()
  223. #-----------------------------------------------------------------------------
  224. # QtTesting
  225. #
  226. option(CTK_USE_QTTESTING "Enable/Disable QtTesting" OFF)
  227. mark_as_advanced(CTK_USE_QTTESTING)
  228. #-----------------------------------------------------------------------------
  229. # Coverage
  230. #
  231. option(WITH_COVERAGE "Enable/Disable coverage" OFF)
  232. mark_as_advanced(WITH_COVERAGE)
  233. #-----------------------------------------------------------------------------
  234. # Documentation
  235. #
  236. option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
  237. mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)
  238. set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  239. CACHE PATH "Where documentation archives should be stored")
  240. mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
  241. #-----------------------------------------------------------------------------
  242. # Additional CXX/C Flags
  243. #
  244. set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
  245. mark_as_advanced(ADDITIONAL_C_FLAGS)
  246. set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
  247. mark_as_advanced(ADDITIONAL_CXX_FLAGS)
  248. #-----------------------------------------------------------------------------
  249. # Set symbol visibility Flags
  250. #
  251. ctkFunctionGetCompilerVisibilityFlags(VISIBILITY_CXX_FLAGS)
  252. #-----------------------------------------------------------------------------
  253. # Set coverage Flags
  254. #
  255. if(WITH_COVERAGE)
  256. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  257. set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")
  258. set(COVERAGE_CXX_FLAGS ${coverage_flags})
  259. set(COVERAGE_C_FLAGS ${coverage_flags})
  260. endif()
  261. endif()
  262. #-----------------------------------------------------------------------------
  263. # CTK C/CXX Flags
  264. #
  265. set(CTK_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
  266. set(CTK_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
  267. if(CMAKE_COMPILER_IS_GNUCXX)
  268. set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2")
  269. ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)
  270. ctkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags)
  271. ctkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
  272. # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so
  273. # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag.
  274. # Doing so should allow to build package made for distribution using older linux distro.
  275. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0"))
  276. ctkFunctionCheckCompilerFlags("-fstack-protector-all" cflags)
  277. endif()
  278. if(MINGW)
  279. # suppress warnings about auto imported symbols
  280. set(CTK_CXX_FLAGS "-Wl,--enable-auto-import ${CTK_CXX_FLAGS}")
  281. endif()
  282. set(CTK_C_FLAGS "${cflags} ${CTK_C_FLAGS}")
  283. set(CTK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${CTK_CXX_FLAGS}")
  284. endif()
  285. if(MSVC)
  286. set(msvc_suppressed_warnings
  287. "/wd4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  288. )
  289. set(CTK_CXX_FLAGS "${CTK_CXX_FLAGS} ${msvc_suppressed_warnings}")
  290. endif()
  291. #-----------------------------------------------------------------------------
  292. # QT
  293. #
  294. ctkMacroSetupQt()
  295. # Update CTK_BASE_LIBRARIES with QT libraries
  296. if(QT4_FOUND)
  297. set(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)
  298. endif()
  299. #-----------------------------------------------------------------------------
  300. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  301. # before the SuperBuild script is included
  302. #
  303. #-----------------------------------------------------------------------------
  304. # High-Level CTK options
  305. # The ctk_enable_option macro expects a logical expression after the first
  306. # three arguments. This expression should only contain build option names
  307. # which belong to leafs in the required dependency tree.
  308. # The CTK infrastructure for high-level DICOM support. This includes
  309. # DICOM indexing, networking, and GUI widgets.
  310. ctk_enable_option(DICOM "Enable default DICOM support" OFF
  311. CTK_LIB_DICOM/Widgets)
  312. # The CTK infrastructure for building a DICOM Part 19 compliant application
  313. # host and/or hosted application. This will not enable any example plugins
  314. # or executables (enable CTK_ENABLE_EXAMPLES for that).
  315. ctk_enable_option(DICOMApplicationHosting "Enable DICOM Part 19 Application Hosting support" OFF
  316. CTK_PLUGIN_org.commontk.dah.host AND CTK_PLUGIN_org.commontk.dah.hostedapp)
  317. # The CTK Qt Widgets. This will enable the Qt Widget library only.
  318. # It might trigger the enabling of other widget libraries in combination
  319. # with other enabled options.
  320. ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF
  321. CTK_LIB_Widgets)
  322. # The CTK Plugin Framework, a dynamic component system based on OSGi.
  323. # This will enable only the framework itself.
  324. ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF
  325. CTK_LIB_PluginFramework)
  326. #-----------------------------------------------------------------------------
  327. # Special "BUILD ALL" options
  328. # Build all CTK plug-ins
  329. option(CTK_BUILD_ALL_PLUGINS "Build all CTK plug-ins" OFF)
  330. # Build all CTK libraries
  331. option(CTK_BUILD_ALL_LIBRARIES "Build all CTK libraries" OFF)
  332. # Build all CTK applications
  333. option(CTK_BUILD_ALL_APPS "Build all CTK applications" OFF)
  334. # Build everything
  335. option(CTK_BUILD_ALL "Build everything in CTK" OFF)
  336. if(CTK_BUILD_ALL)
  337. set(CTK_BUILD_ALL_PLUGINS 1)
  338. set(CTK_BUILD_ALL_LIBRARIES 1)
  339. set(CTK_BUILD_ALL_APPS 1)
  340. endif()
  341. #-----------------------------------------------------------------------------
  342. # Other options
  343. # The CTK Python Wrapping
  344. ctk_enable_option(Python_Wrapping "Wrap CTK classes using Qt meta-object system into Python language" OFF
  345. CTK_LIB_Scripting/Python/Core)
  346. # Build examples
  347. # Create the logical expression containing the minium set of required options
  348. # for the CTK_BUILD_EXAMPLES option to be ON
  349. set(_build_examples_logical_expr)
  350. foreach(_app ${CTK_ENABLED_APPS})
  351. list(APPEND _build_examples_logical_expr CTK_APP_${_app} AND)
  352. endforeach()
  353. if(_build_examples_logical_expr)
  354. list(REMOVE_AT _build_examples_logical_expr -1)
  355. endif()
  356. ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF
  357. ${_build_examples_logical_expr})
  358. # Git protocol option
  359. option(CTK_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
  360. mark_as_advanced(CTK_USE_GIT_PROTOCOL)
  361. set(git_protocol "git")
  362. if(NOT CTK_USE_GIT_PROTOCOL)
  363. set(git_protocol "http")
  364. endif()
  365. # Let's mark as advanced some default properties
  366. mark_as_advanced(CMAKE_INSTALL_PREFIX)
  367. mark_as_advanced(DART_TESTING_TIMEOUT)
  368. # KWStyle
  369. option(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  370. mark_as_advanced(CTK_USE_KWSTYLE)
  371. # Qt Designer Plugins
  372. option(CTK_BUILD_QTDESIGNER_PLUGINS "Build Qt Designer plugins" ON)
  373. mark_as_advanced(CTK_BUILD_QTDESIGNER_PLUGINS)
  374. #-----------------------------------------------------------------------------
  375. # CTK Libraries
  376. #
  377. ctk_lib_option(Core
  378. "Build the Core library" ON)
  379. ctk_lib_option(PluginFramework
  380. "Build the Plugin Framework" OFF
  381. CTK_ENABLE_PluginFramework)
  382. ctk_lib_option(Widgets
  383. "Build the Widgets library" OFF
  384. CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES) OR CTK_USE_QTTESTING)
  385. ctk_lib_option(DICOM/Core
  386. "Build the DICOM Core library" OFF
  387. CTK_ENABLE_DICOM OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
  388. ctk_lib_option(DICOM/Widgets
  389. "Build the DICOM Widgets library" OFF
  390. CTK_ENABLE_DICOM AND CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
  391. ctk_lib_option(ImageProcessing/ITK/Core
  392. "Build the ITK Core library" OFF)
  393. ctk_lib_option(Scripting/Python/Core
  394. "Build the Python Core library" OFF)
  395. ctk_lib_option(Scripting/Python/Widgets
  396. "Build the Python Widgets library" OFF
  397. CTK_LIB_Widgets AND CTK_ENABLE_Python_Wrapping)
  398. ctk_lib_option(Visualization/VTK/Core
  399. "Build the VTK Core library" OFF)
  400. ctk_lib_option(Visualization/VTK/Widgets
  401. "Build the VTK Widgets library" OFF)
  402. ctk_lib_option(CommandLineModules/Core
  403. "Build the Command Line Module core library" OFF)
  404. ctk_lib_option(CommandLineModules/Frontend/QtWebKit
  405. "Build the QtWebKit based Command Line Module front-end" OFF)
  406. ctk_lib_option(CommandLineModules/Frontend/QtGui
  407. "Build the QtGui based Command Line Module front-end" OFF)
  408. ctk_lib_option(CommandLineModules/Backend/LocalProcess
  409. "Build the Command Line Module back-end for local processes" OFF)
  410. ctk_lib_option(CommandLineModules/Backend/FunctionPointer
  411. "Build the Command Line Module back-end for function pointers" OFF)
  412. ctk_lib_option(XNAT/Core
  413. "Build the XNAT Core library" OFF)
  414. ctk_lib_option(XNAT/Widgets
  415. "Build the XNAT Widgets library" OFF)
  416. #ctk_lib_option(Visualization/XIP
  417. # "Build the XIP library" OFF)
  418. # Save the set of enabled libs in a cache file
  419. set(_enabled_libs)
  420. foreach(_lib ${CTK_LIBS})
  421. if(CTK_LIB_${_lib})
  422. list(APPEND _enabled_libs ${_lib})
  423. endif()
  424. endforeach()
  425. set(CTK_ENABLED_LIBS ${_enabled_libs} CACHE INTERNAL "" FORCE)
  426. #-----------------------------------------------------------------------------
  427. # CTK Applications - Use ON or OFF to indicate if the application should be built by default
  428. #
  429. ctk_app_option(ctkDICOM
  430. "Build the DICOM example application" 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. qRestAPI
  698. OpenIGTLink
  699. XIP
  700. ITK
  701. )
  702. #-----------------------------------------------------------------------------
  703. # Check out the ExternalProjectsContrib repository
  704. if(CTK_USE_CONTRIBUTED_PLUGINS)
  705. if(CTK_SUPERBUILD)
  706. ctkFunctionCheckoutRepo(
  707. NAME ExternalProjectsContrib
  708. GIT_URL github.com/commontk/ExternalProjectsContrib.git
  709. GIT_TAG 97dcdc261b
  710. )
  711. endif()
  712. file(GLOB _contrib_scripts ${ExternalProjectsContrib_DIR}/*.cmake)
  713. foreach(_contrib_script ${_contrib_scripts})
  714. get_filename_component(_script_name ${_contrib_script} NAME_WE)
  715. list(APPEND CTK_POSSIBLE_DEPENDENCIES ${_script_name})
  716. set(${_script_name}_FILEPATH ${_contrib_script})
  717. endforeach()
  718. endif()
  719. set(CTK_DEPENDENCIES) # This variable will contain the list of required CTK dependencies
  720. include(CMake/ctkBlockCheckDependencies.cmake)
  721. #-----------------------------------------------------------------------------
  722. # Superbuild script
  723. #
  724. if(CTK_SUPERBUILD)
  725. include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  726. return()
  727. endif()
  728. #-----------------------------------------------------------------------------
  729. # Expand variables containing include and library directories for external projects
  730. # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions
  731. foreach(_external_target ${EXTERNAL_TARGETS})
  732. if(${_external_target}_FIND_PACKAGE_CMD)
  733. #message("Calling find_package(${${_external_target}_FIND_PACKAGE_CMD})")
  734. find_package(${${_external_target}_FIND_PACKAGE_CMD} REQUIRED)
  735. endif()
  736. endforeach()
  737. foreach(_external_target ${EXTERNAL_TARGETS})
  738. if(${_external_target}_INCLUDE_DIRS)
  739. #message("[${_external_target}] Resolving include variables: ${${_external_target}_INCLUDE_DIRS}")
  740. foreach(_include_variable ${${_external_target}_INCLUDE_DIRS})
  741. #message("[${_external_target}] Appending ${${_include_variable}}")
  742. if(${_include_variable})
  743. list(APPEND ${_external_target}_INCLUDE_DIRS ${${_include_variable}})
  744. else()
  745. list(APPEND ${_external_target}_INCLUDE_DIRS ${_include_variable})
  746. endif()
  747. #message("[${_external_target}] New dirs: ${${_external_target}_INCLUDE_DIRS}")
  748. endforeach()
  749. #message("[${_external_target}] Appended dirs: ${${_external_target}_INCLUDE_DIRS}")
  750. endif()
  751. if(${_external_target}_LIBRARY_DIRS)
  752. #message("[${_external_target}] Resolving library variables: ${${_external_target}_LIBRARY_DIRS}")
  753. foreach(_library_variable ${${_external_target}_LIBRARY_DIRS})
  754. #message("[${_external_target}] Appending ${${_library_variable}}")
  755. if(${_library_variable})
  756. list(APPEND ${_external_target}_LIBRARY_DIRS ${${_library_variable}})
  757. else()
  758. list(APPEND ${_external_target}_LIBRARY_DIRS ${_library_variable})
  759. endif()
  760. #message("[${_external_target}] New dirs: ${${_external_target}_LIBRARY_DIRS}")
  761. endforeach()
  762. #message("[${_external_target}] Appended dirs: ${${_external_target}_LIBRARY_DIRS}")
  763. endif()
  764. endforeach()
  765. set(CTK_WRAP_PYTHONQT_USE_VTK ${CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK})
  766. #-----------------------------------------------------------------------------
  767. # CTK_SUPERBUILD_BINARY_DIR
  768. # If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
  769. # In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
  770. if(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
  771. set(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
  772. endif()
  773. #-----------------------------------------------------------------------------
  774. # Configure files with settings
  775. #
  776. configure_file(${CTK_SOURCE_DIR}/CMake/UseCTK.cmake.in
  777. ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
  778. set(CTK_CONFIG_H_INCLUDE_DIR ${CTK_BINARY_DIR})
  779. #-----------------------------------------------------------------------------
  780. # Set C/CXX Flags
  781. #
  782. set(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)
  783. set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
  784. #-----------------------------------------------------------------------------
  785. # Set the header template which defines custom export/import macros
  786. # for shared libraries
  787. #
  788. set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")
  789. #-----------------------------------------------------------------------------
  790. # Setup testing environment before Libs are added
  791. #
  792. add_subdirectory(Libs/Testing)
  793. #-----------------------------------------------------------------------------
  794. # Add CTK library subdirectories
  795. #
  796. foreach(lib ${CTK_LIBS})
  797. if(CTK_LIB_${lib})
  798. add_subdirectory(Libs/${lib})
  799. endif()
  800. # Always add the Documentation sub-directory for additional processing
  801. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation/CMakeLists.txt)
  802. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/Documentation)
  803. endif()
  804. endforeach()
  805. # Add the CommandLineModules root directory for additional processing
  806. add_subdirectory(Libs/CommandLineModules)
  807. #-----------------------------------------------------------------------------
  808. if(CTK_USE_QTTESTING)
  809. add_subdirectory(Libs/QtTesting)
  810. endif()
  811. #-----------------------------------------------------------------------------
  812. # Add CTK plugin subdirectories
  813. #
  814. foreach(plugin ${CTK_PLUGINS})
  815. if(CTK_PLUGIN_${plugin})
  816. if(${plugin}_SOURCE_DIR)
  817. add_subdirectory(${${plugin}_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Plugins/${plugin})
  818. else()
  819. add_subdirectory(Plugins/${plugin})
  820. endif()
  821. endif()
  822. endforeach()
  823. #-----------------------------------------------------------------------------
  824. # Add CTK application subdirectories
  825. #
  826. foreach(app ${CTK_APPS})
  827. IF (CTK_APP_${app})
  828. add_subdirectory(Applications/${app})
  829. endif()
  830. endforeach()
  831. if(BUILD_TESTING)
  832. add_subdirectory(Applications/Testing)
  833. endif()
  834. #-----------------------------------------------------------------------------
  835. # Add general purpose subdirectories
  836. #
  837. #add_subdirectory(Testing)
  838. #add_subdirectory(Examples)
  839. #-----------------------------------------------------------------------------
  840. # Style Checking configuration
  841. #
  842. include(Utilities/KWStyle/KWStyle.cmake)
  843. #---------------------------------------------------------------------------
  844. # Documentation
  845. #
  846. add_subdirectory( Documentation )
  847. #-----------------------------------------------------------------------------
  848. # The commands in this directory are intended to be executed as
  849. # the end of the whole configuration process, as a "last step".
  850. # This directory is typically the last SUBDIRS in the main CMakeLists.txt.
  851. add_subdirectory(CMake/LastConfigureStep)