CMakeLists.txt 39 KB

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