CMakeLists.txt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) 2010 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.commontk.org/LICENSE
  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)
  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. PROJECT(CTK)
  47. #-----------------------------------------------------------------------------
  48. #-----------------------------------------------------------------------------
  49. # Default to shared library
  50. SET(CTK_LIBRARY_MODE "SHARED")
  51. SET(CTK_BUILD_SHARED_LIBS TRUE)
  52. #-----------------------------------------------------------------------------
  53. # Superbuild Option - Enabled by default
  54. #
  55. OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
  56. MARK_AS_ADVANCED(CTK_SUPERBUILD)
  57. #-----------------------------------------------------------------------------
  58. # Output directories.
  59. #
  60. FOREACH(type LIBRARY RUNTIME ARCHIVE)
  61. # Make sure the directory exists
  62. IF(DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY
  63. AND NOT EXISTS ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  64. MESSAGE(FATAL_ERROR "CTK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${CTK_CMAKE_${type}_OUTPUT_DIRECTORY}]")
  65. ENDIF()
  66. IF(CTK_SUPERBUILD)
  67. SET(output_dir ${CTK_BINARY_DIR}/bin)
  68. IF(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  69. SET(CTK_CMAKE_${type}_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
  70. ENDIF()
  71. ELSE()
  72. IF(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)
  73. SET(output_dir ${CTK_BINARY_DIR}/bin)
  74. ELSE()
  75. SET(output_dir ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})
  76. ENDIF()
  77. ENDIF()
  78. SET(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
  79. ENDFOREACH()
  80. #-----------------------------------------------------------------------------
  81. # CTK version number. An even minor number corresponds to releases.
  82. #
  83. SET(CTK_MAJOR_VERSION 0)
  84. SET(CTK_MINOR_VERSION 1)
  85. SET(CTK_BUILD_VERSION 0)
  86. SET(CTK_VERSION
  87. "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_BUILD_VERSION}")
  88. # Append the library version information to the library target
  89. # properties. A parent project may set its own properties and/or may
  90. # block this.
  91. IF(NOT CTK_NO_LIBRARY_VERSION)
  92. SET(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
  93. VERSION "${CTK_VERSION}"
  94. SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
  95. )
  96. ENDIF()
  97. #-----------------------------------------------------------------------------
  98. # Install directories, used for install rules.
  99. #
  100. SET(CTK_INSTALL_BIN_DIR "bin")
  101. SET(CTK_INSTALL_LIB_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  102. SET(CTK_INSTALL_INCLUDE_DIR "include/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")
  103. SET(CTK_INSTALL_DOC_DIR "doc")
  104. #-----------------------------------------------------------------------------
  105. # Update CMake module path
  106. # Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
  107. #
  108. SET(CMAKE_MODULE_PATH
  109. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
  110. "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  111. ${CMAKE_MODULE_PATH})
  112. #-----------------------------------------------------------------------------
  113. # Clear CTK_BASE_INCLUDE_DIRS, CTK_BASE_LIBRARIES and CTK_WRAPPED_LIBRARIES_PYTHONQT
  114. #
  115. SET(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
  116. SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
  117. SET(CTK_WRAPPED_LIBRARIES_PYTHONQT CACHE INTERNAL "CTK libraries wrapped using PythonQt" FORCE)
  118. # Variable use in CTKConfig.cmake.in
  119. SET(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
  120. #-----------------------------------------------------------------------------
  121. # CMake Function(s) and Macro(s)
  122. #
  123. INCLUDE(CMake/ctkMacroParseArguments.cmake)
  124. INCLUDE(CMake/ctkMacroSetPaths.cmake)
  125. INCLUDE(CMake/ctkMacroListFilter.cmake)
  126. INCLUDE(CMake/ctkMacroBuildLib.cmake)
  127. INCLUDE(CMake/ctkMacroBuildPlugin.cmake)
  128. INCLUDE(CMake/ctkMacroBuildApp.cmake)
  129. INCLUDE(CMake/ctkMacroBuildQtDesignerPlugin.cmake)
  130. INCLUDE(CMake/ctkMacroCompilePythonScript.cmake)
  131. INCLUDE(CMake/ctkMacroWrapPythonQt.cmake)
  132. INCLUDE(CMake/ctkMacroSetupQt.cmake)
  133. INCLUDE(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macros
  134. INCLUDE(CMake/ctkFunctionExtractOptionNameAndValue.cmake)
  135. INCLUDE(CMake/ctkMacroValidateBuildOptions.cmake)
  136. INCLUDE(CMake/ctkMacroAddCtkLibraryOptions.cmake)
  137. INCLUDE(CMake/ctkFunctionGenerateDGraphInput.cmake)
  138. INCLUDE(CMake/ctkFunctionGenerateProjectXml.cmake)
  139. INCLUDE(CMake/ctkFunctionGeneratePluginManifest.cmake)
  140. INCLUDE(CMake/ctkMacroGeneratePluginResourceFile.cmake)
  141. INCLUDE(CMake/ctkFunctionCheckCompilerFlags.cmake)
  142. # Used by CTKGenerateCTKConfig.cmake
  143. SET(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
  144. SET(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
  145. #-----------------------------------------------------------------------------
  146. # Testing
  147. #
  148. OPTION(BUILD_TESTING "Test the project" ON)
  149. IF(BUILD_TESTING)
  150. ENABLE_TESTING()
  151. INCLUDE(CTest)
  152. SET(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  153. MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
  154. # Setup file for setting custom ctest vars
  155. CONFIGURE_FILE(
  156. CMake/CTestCustom.cmake.in
  157. ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
  158. @ONLY
  159. )
  160. # Configuration for the CMake-generated test driver
  161. SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
  162. SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
  163. try
  164. {")
  165. SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
  166. catch( std::exception & excp )
  167. {
  168. fprintf(stderr,\"%s\\n\",excp.what());
  169. return EXIT_FAILURE;
  170. }
  171. catch( ... )
  172. {
  173. printf(\"Exception caught in the test driver\\n\");
  174. return EXIT_FAILURE;
  175. }
  176. ")
  177. ENDIF()
  178. #-----------------------------------------------------------------------------
  179. # Coverage
  180. #
  181. OPTION(WITH_COVERAGE "Enable/Disable coverage" OFF)
  182. #-----------------------------------------------------------------------------
  183. # Documentation
  184. #
  185. OPTION(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
  186. MARK_AS_ADVANCED(DOCUMENTATION_TARGET_IN_ALL)
  187. OPTION(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY "Where documentation archives should be stored" ${CMAKE_CURRENT_BINARY_DIR})
  188. MARK_AS_ADVANCED(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
  189. #-----------------------------------------------------------------------------
  190. # Additional CXX/C Flags
  191. #
  192. SET(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
  193. MARK_AS_ADVANCED(ADDITIONAL_C_FLAGS)
  194. SET(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
  195. MARK_AS_ADVANCED(ADDITIONAL_CXX_FLAGS)
  196. #-----------------------------------------------------------------------------
  197. # Set symbol visibility Flags
  198. #
  199. # MinGW does not export all symbols automatically, so no need to set flags
  200. IF(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW)
  201. SET(VISIBILITY_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
  202. ENDIF()
  203. #-----------------------------------------------------------------------------
  204. # Set coverage Flags
  205. #
  206. IF(WITH_COVERAGE)
  207. IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  208. SET(coverage_flags "-g -fprofile-arcs -ftest-coverage -O3 -DNDEBUG")
  209. SET(COVERAGE_CXX_FLAGS ${coverage_flags})
  210. SET(COVERAGE_C_FLAGS ${coverage_flags})
  211. ENDIF()
  212. ENDIF()
  213. #-----------------------------------------------------------------------------
  214. # CTK C/CXX Flags
  215. #
  216. SET(CTK_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
  217. SET(CTK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
  218. IF(CMAKE_COMPILER_IS_GNUCXX)
  219. SET(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2")
  220. ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)
  221. ctkFunctionCheckCompilerFlags("-fstack-protector-all" cflags)
  222. IF(MINGW)
  223. # suppress warnings about auto imported symbols
  224. SET(CTK_CXX_FLAGS "-Wl,--enable-auto-import ${CTK_CXX_FLAGS}")
  225. ENDIF()
  226. SET(CTK_C_FLAGS "${cflags} ${CTK_C_FLAGS}")
  227. SET(CTK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${CTK_CXX_FLAGS}")
  228. ENDIF()
  229. #-----------------------------------------------------------------------------
  230. # QT
  231. #
  232. ctkMacroSetupQt()
  233. # Update CTK_BASE_LIBRARIES with QT libraries
  234. IF(QT4_FOUND)
  235. SET(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)
  236. ENDIF()
  237. #-----------------------------------------------------------------------------
  238. # CTK Libraries - Use ON or OFF to indicate if the library should be built by default
  239. #
  240. SET(CTK_LIBS
  241. Core:ON
  242. PluginFramework:ON
  243. Widgets:OFF
  244. DICOM/Core:OFF
  245. DICOM/Widgets:OFF
  246. Messaging/Core:OFF
  247. Scripting/Python/Core:OFF
  248. Scripting/Python/Widgets:OFF
  249. Visualization/VTK/Core:OFF
  250. Visualization/VTK/Widgets:OFF
  251. Visualization/XIP:OFF
  252. )
  253. #-----------------------------------------------------------------------------
  254. # CTK Plugins - Use ON or OFF to indicate if the plugin should be built by default
  255. #
  256. SET(CTK_PLUGINS
  257. org.commontk.eventbus:ON
  258. org.commontk.cli:OFF
  259. org.commontk.plugingenerator.core:OFF
  260. org.commontk.plugingenerator.ui:OFF
  261. )
  262. #-----------------------------------------------------------------------------
  263. # CTK Applications - Use ON or OFF to indicate if the application should be built by default
  264. #
  265. SET(CTK_APPLICATIONS
  266. ctkCLIPluginExplorer:OFF
  267. ctkDICOM:OFF
  268. ctkDICOMIndexer:OFF
  269. ctkDICOMDemoSCU:OFF
  270. ctkDICOMQuery:OFF
  271. ctkDICOMRetrieve:OFF
  272. ctkPluginBrowser:OFF
  273. ctkPluginGenerator:OFF
  274. ctkSimplePythonShell:OFF
  275. )
  276. #-----------------------------------------------------------------------------
  277. # To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
  278. # before the SuperBuild script is included
  279. #
  280. # Let's mark as advanced some default properties
  281. MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
  282. MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
  283. # KWStyle
  284. OPTION(CTK_USE_KWSTYLE "Enable sourcecode-based style tests." OFF)
  285. #MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
  286. #---------------------------------------------------------------------------
  287. # Will contain a list of sub-directory without option ON or OFF
  288. #
  289. SET(CTK_LIBS_SUBDIRS )
  290. SET(CTK_PLUGINS_SUBDIRS )
  291. SET(CTK_APPLICATIONS_SUBDIRS )
  292. #-----------------------------------------------------------------------------
  293. # Build options associated with CTK libraries
  294. # Note also that if
  295. # the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists and look like:
  296. #
  297. # SET(ctk_library_options
  298. # OPT1:OFF
  299. # OPT2:ON
  300. # )
  301. #
  302. # In addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
  303. # will also be available in CMake configure menu:
  304. # CTK_LIB_<DIR>/<LIBNAME>_OPT1 (set to OFF)
  305. # CTK_LIB_<DIR>/<LIBNAME>_OPT2 (set to ON)
  306. #
  307. SET(ctk_lib_options_list) # This list will be updated in ctkFunctionExtractOptionNameAndValue
  308. FOREACH(lib ${CTK_LIBS})
  309. ctkFunctionExtractOptionNameAndValue(${lib} lib_name lib_value)
  310. OPTION(CTK_LIB_${lib_name} "Enable ${lib_name} Library." ${lib_value})
  311. ctkMacroAddCtkLibraryOptions(${lib_name})
  312. LIST(APPEND CTK_LIBS_SUBDIRS "${lib_name}")
  313. ENDFOREACH()
  314. # Build options associated with CTK plugins
  315. FOREACH(plugin ${CTK_PLUGINS})
  316. ctkFunctionExtractOptionNameAndValue(${plugin} plugin_name plugin_value)
  317. OPTION(CTK_PLUGIN_${plugin_name} "Build ${plugin_name} Plugin." ${plugin_value})
  318. LIST(APPEND CTK_PLUGINS_SUBDIRS "${plugin_name}")
  319. ENDFOREACH()
  320. # Create a file with variables containing the paths to the source, binary, and library directory
  321. # of each enabled plugin. This is needed to setup include and library dependencies to other plugins
  322. #SET(CTK_PLUGIN_LIST "${CMAKE_CURRENT_BINARY_DIR}/ctkPluginList.cmake")
  323. #SET(CTK_PLUGINS_SUBDIRS_ENABLED )
  324. #FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
  325. # IF (CTK_PLUGIN_${plugin})
  326. # LIST(APPEND CTK_PLUGINS_SUBDIRS_ENABLED Plugins/${plugin})
  327. # ENDIF()
  328. #ENDFOREACH()
  329. #ctkMacroGeneratePluginList(FILE ${CTK_PLUGIN_LIST}
  330. # DIRECTORIES ${CTK_PLUGINS_SUBDIRS_ENABLED})
  331. # Build options associated with CTK applications
  332. FOREACH(app ${CTK_APPLICATIONS})
  333. ctkFunctionExtractOptionNameAndValue(${app} app_name app_value)
  334. OPTION(CTK_APP_${app_name} "Build ${app_name} Application." ${app_value})
  335. LIST(APPEND CTK_APPLICATIONS_SUBDIRS "${app_name}")
  336. ENDFOREACH()
  337. #-----------------------------------------------------------------------------
  338. # CTK Python wrapping - Propose the option only if CTK_LIB_Scriping/Python/Core is ON
  339. IF(CTK_LIB_Scripting/Python/Core)
  340. OPTION(CTK_WRAP_PYTHONQT_FULL "Wrap CTK classes using Qt meta-object system into Python language" OFF)
  341. OPTION(CTK_WRAP_PYTHONQT_LIGHT "Wrap CTK classes using Qt meta-object system into Python language" OFF)
  342. IF(CTK_WRAP_PYTHONQT_FULL AND CTK_WRAP_PYTHONQT_LIGHT)
  343. MESSAGE(SEND_ERROR "CTK_WRAP_PYTHONQT_{LIGHT,FULL} options are mutually exclusive. Please enable only one !")
  344. ENDIF()
  345. ELSE()
  346. # Note that an unset boolean variable is considered to be False
  347. UNSET(CTK_WRAP_PYTHONQT_FULL CACHE)
  348. UNSET(CTK_WRAP_PYTHONQT_LIGHT CACHE)
  349. ENDIF()
  350. #-----------------------------------------------------------------------------
  351. # Generate target_directories list - List of directory corresponding to the different
  352. # libraries, plugins and applications associated with the corresponding option name.
  353. #
  354. # Create list of directories corresponding to the enabled targets
  355. SET(target_directories)
  356. FOREACH(lib ${CTK_LIBS_SUBDIRS})
  357. SET(option_name CTK_LIB_${lib})
  358. LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^${option_name}")
  359. ENDFOREACH()
  360. FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
  361. SET(option_name CTK_PLUGIN_${plugin})
  362. LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^${option_name}")
  363. ENDFOREACH()
  364. FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
  365. SET(option_name CTK_APP_${app})
  366. LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^${option_name}")
  367. ENDFOREACH()
  368. #MESSAGE(STATUS target_directories:${target_directories})
  369. #-----------------------------------------------------------------------------
  370. # Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
  371. # topological order.
  372. TRY_COMPILE(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
  373. DGraph
  374. CMAKE_FLAGS
  375. -DQT_QMAKE_EXECUTABLE:BOOL=${QT_QMAKE_EXECUTABLE}
  376. -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
  377. OUTPUT_VARIABLE output)
  378. IF(NOT RESULT_VAR)
  379. MESSAGE(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
  380. ENDIF()
  381. FIND_PROGRAM(DGraph_EXECUTABLE DGraph
  382. "${CTK_BINARY_DIR}/Utilities/DGraph/"
  383. "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
  384. "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
  385. "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
  386. MARK_AS_ADVANCED(DGraph_EXECUTABLE)
  387. #-----------------------------------------------------------------------------
  388. # Let's make sure the enabled/disabled libraries, plugins or applications are coherent
  389. #
  390. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" FALSE)
  391. ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
  392. #-----------------------------------------------------------------------------
  393. # DGraph
  394. #
  395. # Generate DGraph input file expected by DGraph
  396. ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" TRUE)
  397. # Obtain list of target ordered topologically
  398. ctkMacroSetPaths("${QT_INSTALLED_LIBRARY_DIR}")
  399. EXECUTE_PROCESS(
  400. COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
  401. WORKING_DIRECTORY ${CTK_BINARY_DIR}
  402. RESULT_VARIABLE RESULT_VAR
  403. OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS_OUTPUT
  404. ERROR_VARIABLE error
  405. OUTPUT_STRIP_TRAILING_WHITESPACE
  406. )
  407. IF(RESULT_VAR)
  408. MESSAGE(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
  409. ENDIF()
  410. # Convert 'CTEST_PROJECT_SUBPROJECTS_OUTPUT' to a list
  411. STRING(REPLACE " " "\\;" CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS_OUTPUT})
  412. SET(CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS})
  413. # If the list of subproject is empty, let's at least build CTKCore
  414. LIST(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
  415. IF (subproject_count EQUAL 0)
  416. SET(CTEST_PROJECT_SUBPROJECTS CTKCore)
  417. ENDIF()
  418. # Configure CTestConfigSubProject.cmake used that could be used by CTest scripts
  419. CONFIGURE_FILE(${CTK_SOURCE_DIR}/CTestConfigSubProject.cmake.in
  420. ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
  421. #-----------------------------------------------------------------------------
  422. # Project.xml
  423. #
  424. # Generate Project.xml file expected by the CTest driver script
  425. ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
  426. #-----------------------------------------------------------------------------
  427. # Superbuild script
  428. #
  429. IF(CTK_SUPERBUILD)
  430. INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
  431. RETURN()
  432. ENDIF()
  433. #-----------------------------------------------------------------------------
  434. # CTK_SUPERBUILD_BINARY_DIR
  435. # If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
  436. # In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
  437. IF(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
  438. SET(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
  439. ENDIF()
  440. #-----------------------------------------------------------------------------
  441. # Configure files with settings
  442. #
  443. CONFIGURE_FILE(${CTK_SOURCE_DIR}/UseCTK.cmake.in
  444. ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
  445. #-----------------------------------------------------------------------------
  446. # Set C/CXX Flags
  447. #
  448. SET(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)
  449. SET(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
  450. #-----------------------------------------------------------------------------
  451. # Add CTK library subdirectories
  452. #
  453. FOREACH(lib ${CTK_LIBS_SUBDIRS})
  454. IF (CTK_LIB_${lib})
  455. ADD_SUBDIRECTORY(Libs/${lib})
  456. ENDIF()
  457. ENDFOREACH()
  458. #-----------------------------------------------------------------------------
  459. # Add CTK plugin subdirectories
  460. #
  461. FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
  462. IF(CTK_PLUGIN_${plugin})
  463. ADD_SUBDIRECTORY(Plugins/${plugin})
  464. ENDIF()
  465. ENDFOREACH()
  466. #-----------------------------------------------------------------------------
  467. # Add CTK application subdirectories
  468. #
  469. FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
  470. IF (CTK_APP_${app})
  471. ADD_SUBDIRECTORY(Applications/${app})
  472. ENDIF()
  473. ENDFOREACH()
  474. #-----------------------------------------------------------------------------
  475. # Add general purpose subdirectories
  476. #
  477. #ADD_SUBDIRECTORY(Testing)
  478. #ADD_SUBDIRECTORY(Examples)
  479. #-----------------------------------------------------------------------------
  480. # Style Checking configuration
  481. #
  482. INCLUDE(Utilities/KWStyle/KWStyle.cmake)
  483. #---------------------------------------------------------------------------
  484. # Documentation
  485. #
  486. ADD_SUBDIRECTORY( Documentation )
  487. #-----------------------------------------------------------------------------
  488. # The commands in this directory are intended to be executed as
  489. # the end of the whole configuration process, as a "last step".
  490. # This directory is typically the last SUBDIRS in the main CMakeLists.txt.
  491. ADD_SUBDIRECTORY(Utilities/LastConfigureStep)