SuperBuild.cmake 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. SET(cmake_version_required "2.8")
  2. SET(cmake_version_required_dash "2-8")
  3. CMAKE_MINIMUM_REQUIRED(VERSION ${cmake_version_required})
  4. #
  5. # CTK_KWSTYLE_EXECUTABLE
  6. # DCMTK_DIR
  7. # QT_QMAKE_EXECUTABLE
  8. #
  9. #-----------------------------------------------------------------------------
  10. # Enable and setup External project global properties
  11. #
  12. INCLUDE(ExternalProject)
  13. SET(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals")
  14. SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base})
  15. SET(ep_install_dir ${ep_base}/Install)
  16. SET(ep_build_dir ${ep_base}/Build)
  17. SET(ep_source_dir ${ep_base}/Source)
  18. #SET(ep_parallelism_level)
  19. SET(ep_build_shared_libs ON)
  20. SET(ep_build_testing OFF)
  21. SET(ep_common_args
  22. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  23. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  24. -DBUILD_TESTING:BOOL=${ep_build_testing}
  25. )
  26. # Compute -G arg for configuring external projects with the same CMake generator:
  27. IF(CMAKE_EXTRA_GENERATOR)
  28. SET(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
  29. ELSE()
  30. SET(gen "${CMAKE_GENERATOR}")
  31. ENDIF()
  32. # Use this value where semi-colons are needed in ep_add args:
  33. set(sep "^^")
  34. # Find the git executable, used for custom git commands for external projects
  35. # (e.g. for QtMobility)
  36. find_program(Git_EXECUTABLE git DOC "git command line client")
  37. mark_as_advanced(Git_EXECUTABLE)
  38. #-----------------------------------------------------------------------------
  39. # Update CMake module path
  40. #
  41. SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
  42. #-----------------------------------------------------------------------------
  43. # Collect CTK library target dependencies
  44. #
  45. ctkMacroCollectAllTargetLibraries("${CTK_LIBS}" "Libs" ALL_TARGET_LIBRARIES)
  46. ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS}" "Plugins" ALL_TARGET_LIBRARIES)
  47. ctkMacroCollectAllTargetLibraries("${CTK_APPLICATIONS}" "Applications" ALL_TARGET_LIBRARIES)
  48. #MESSAGE(STATUS ALL_TARGET_LIBRARIES:${ALL_TARGET_LIBRARIES})
  49. #-----------------------------------------------------------------------------
  50. # Initialize NON_CTK_DEPENDENCIES variable
  51. #
  52. # Using the variable ALL_TARGET_LIBRARIES initialized above with the help
  53. # of the macro ctkMacroCollectAllTargetLibraries, let's get the list of all Non-CTK dependencies.
  54. # NON_CTK_DEPENDENCIES is expected by the macro ctkMacroShouldAddExternalProject
  55. ctkMacroGetAllNonCTKTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCIES)
  56. #MESSAGE(STATUS NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})
  57. #-----------------------------------------------------------------------------
  58. # Qt is expected to be setup by CTK/CMakeLists.txt just before it includes the SuperBuild script
  59. #
  60. #-----------------------------------------------------------------------------
  61. # KWStyle
  62. #
  63. SET(kwstyle_DEPENDS)
  64. IF(CTK_USE_KWSTYLE)
  65. IF(NOT DEFINED CTK_KWSTYLE_EXECUTABLE)
  66. SET(proj KWStyle-CVSHEAD)
  67. SET(kwstyle_DEPENDS ${proj})
  68. ExternalProject_Add(${proj}
  69. LIST_SEPARATOR ${sep}
  70. CVS_REPOSITORY ":pserver:anoncvs:@public.kitware.com:/cvsroot/KWStyle"
  71. CVS_MODULE "KWStyle"
  72. CMAKE_GENERATOR ${gen}
  73. CMAKE_ARGS
  74. ${ep_common_args}
  75. )
  76. SET(CTK_KWSTYLE_EXECUTABLE ${ep_install_dir}/bin/KWStyle)
  77. ENDIF()
  78. ENDIF()
  79. #-----------------------------------------------------------------------------
  80. # PythonQt
  81. #
  82. SET(PythonQt_DEPENDS)
  83. ctkMacroShouldAddExternalProject(PYTHONQT_LIBRARIES add_project)
  84. IF(${add_project})
  85. # SET(proj PythonQt)
  86. # SET(PythonQt_DEPENDS ${proj})
  87. # ExternalProject_Add(${proj}
  88. # SVN_REPOSITORY "https://pythonqt.svn.sourceforge.net/svnroot/pythonqt/trunk"
  89. # CMAKE_GENERATOR ${gen}
  90. # PATCH_COMMAND ${CMAKE_COMMAND} -P ${pythonqt_patch_script}
  91. # BUILD_COMMAND ""
  92. # CMAKE_ARGS
  93. # ${ep_common_args}
  94. # -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  95. # #${vtk_PYTHON_ARGS}
  96. # INSTALL_COMMAND "")
  97. ENDIF()
  98. #-----------------------------------------------------------------------------
  99. # Utilities/DCMTK
  100. #
  101. SET(DCMTK_DEPENDS)
  102. ctkMacroShouldAddExternalProject(DCMTK_LIBRARIES add_project)
  103. IF(${add_project})
  104. IF(NOT DEFINED DCMTK_DIR)
  105. SET(proj DCMTK)
  106. # MESSAGE(STATUS "Adding project:${proj}")
  107. SET(DCMTK_DEPENDS ${proj})
  108. ExternalProject_Add(${proj}
  109. DOWNLOAD_COMMAND ""
  110. CMAKE_GENERATOR ${gen}
  111. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/${proj}
  112. CMAKE_ARGS
  113. ${ep_common_args}
  114. -DDCMTK_BUILD_APPS:BOOL=ON # Build also dmctk tools (movescu, storescp, ...)
  115. )
  116. SET(DCMTK_DIR ${ep_install_dir})
  117. ENDIF()
  118. ENDIF()
  119. #-----------------------------------------------------------------------------
  120. # Utilities/ZMQ
  121. #
  122. SET(ZMQ_DEPENDS)
  123. ctkMacroShouldAddExternalProject(ZMQ_LIBRARIES add_project)
  124. IF(${add_project})
  125. SET(proj ZMQ)
  126. # MESSAGE(STATUS "Adding project:${proj}")
  127. SET(ZMQ_DEPENDS ${proj})
  128. ExternalProject_Add(${proj}
  129. DOWNLOAD_COMMAND ""
  130. INSTALL_COMMAND ""
  131. CMAKE_GENERATOR ${gen}
  132. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ZMQ
  133. CMAKE_ARGS
  134. ${ep_common_args}
  135. )
  136. ENDIF()
  137. #-----------------------------------------------------------------------------
  138. # QtMobility
  139. #
  140. SET(QtMobility_DEPENDS)
  141. ctkMacroShouldAddExternalProject(QTMOBILITY_QTSERVICEFW_LIBRARIES add_project)
  142. IF(${add_project})
  143. SET(proj QtMobility)
  144. # MESSAGE(STATUS "Adding project:${proj}")
  145. SET(QtMobility_DEPENDS ${proj})
  146. # Configure patch script
  147. SET(qtmobility_src_dir ${ep_source_dir}/${proj})
  148. SET(qtmobility_patch_dir ${CTK_SOURCE_DIR}/Utilities/QtMobility/)
  149. SET(qtmobility_configured_patch_dir ${CTK_BINARY_DIR}/Utilities/QtMobility/)
  150. SET(qtmobility_patchscript
  151. ${CTK_BINARY_DIR}/Utilities/QtMobility/QtMobilityGitBranch1.0-patch.cmake)
  152. CONFIGURE_FILE(
  153. ${CTK_SOURCE_DIR}/Utilities/QtMobility/QtMobilityGitBranch1.0-patch.cmake.in
  154. ${qtmobility_patchscript} @ONLY)
  155. # Define configure options
  156. SET(qtmobility_modules "serviceframework")
  157. SET(qtmobility_build_type "release")
  158. IF(UNIX)
  159. IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
  160. SET(qtmobility_build_type "debug")
  161. ENDIF()
  162. ELSEIF(NOT ${CMAKE_CFG_INTDIR} STREQUAL "Release")
  163. SET(qtmobility_build_type "debug")
  164. ENDIf()
  165. ExternalProject_Add(${proj}
  166. GIT_REPOSITORY git://gitorious.org/qt-mobility/qt-mobility.git
  167. # the patch command is also used to checkout the 1.0 branch
  168. PATCH_COMMAND ${CMAKE_COMMAND} -P ${qtmobility_patchscript}
  169. CONFIGURE_COMMAND <SOURCE_DIR>/configure -${qtmobility_build_type} -libdir ${CMAKE_BINARY_DIR}/CTK-build/bin -no-docs -modules ${qtmobility_modules}
  170. BUILD_IN_SOURCE 1
  171. )
  172. ENDIF()
  173. #-----------------------------------------------------------------------------
  174. # Utilities/OpenIGTLink
  175. #
  176. SET (OpenIGTLink_DEPENDS)
  177. ctkMacroShouldAddExternalProject(OpenIGTLink_LIBRARIES add_project)
  178. IF(${add_project})
  179. IF(NOT DEFINED OpenIGTLink_DIR)
  180. SET(proj OpenIGTLink)
  181. # MESSAGE(STATUS "Adding project:${proj}")
  182. SET(OpenIGTLink_DEPENDS ${proj})
  183. ExternalProject_Add(${proj}
  184. SVN_REPOSITORY "http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink"
  185. INSTALL_COMMAND ""
  186. CMAKE_GENERATOR ${gen}
  187. CMAKE_ARGS
  188. ${ep_common_args}
  189. )
  190. SET(OpenIGTLink_DIR ${ep_build_dir}/${proj})
  191. ENDIF()
  192. ENDIF()
  193. #-----------------------------------------------------------------------------
  194. # XIP
  195. #
  196. SET (XIP_DEPENDS)
  197. ctkMacroShouldAddExternalProject(XIP_LIBRARIES add_project)
  198. IF(${add_project})
  199. SET(proj XIP)
  200. # MESSAGE(STATUS "Adding project:${proj}")
  201. SET(XIP_DEPENDS ${proj})
  202. ExternalProject_Add(${proj}
  203. SVN_REPOSITORY "https://collab01a.scr.siemens.com/svn/xip/releases/latest"
  204. SVN_USERNAME "anonymous"
  205. INSTALL_COMMAND ""
  206. CMAKE_GENERATOR ${gen}
  207. CMAKE_ARGS
  208. ${ep_common_args}
  209. )
  210. ENDIF()
  211. #-----------------------------------------------------------------------------
  212. # CTK Utilities
  213. #
  214. set(proj CTK-Utilities)
  215. ExternalProject_Add(${proj}
  216. DOWNLOAD_COMMAND ""
  217. CONFIGURE_COMMAND ""
  218. BUILD_COMMAND ""
  219. INSTALL_COMMAND ""
  220. DEPENDS
  221. # Mandatory dependencies
  222. ${QtMobility_DEPENDS}
  223. # Optionnal dependencies
  224. ${kwstyle_DEPENDS}
  225. ${DCMTK_DEPENDS}
  226. ${PythonQt_DEPENDS}
  227. ${ZMQ_DEPENDS}
  228. ${OpenIGTLink_DEPENDS}
  229. ${XIP_DEPENDS}
  230. )
  231. #-----------------------------------------------------------------------------
  232. # Generate cmake variable name corresponding to Libs, Plugins and Applications
  233. #
  234. SET(ctk_libs_bool_vars)
  235. FOREACH(lib ${ctk_libs})
  236. LIST(APPEND ctk_libs_bool_vars CTK_LIB_${lib})
  237. ENDFOREACH()
  238. SET(ctk_plugins_bool_vars)
  239. FOREACH(plugin ${ctk_plugins})
  240. LIST(APPEND ctk_plugins_bool_vars CTK_PLUGIN_${plugin})
  241. ENDFOREACH()
  242. SET(ctk_applications_bool_vars)
  243. FOREACH(app ${ctk_applications})
  244. LIST(APPEND ctk_applications_bool_vars CTK_APP_${app})
  245. ENDFOREACH()
  246. #-----------------------------------------------------------------------------
  247. # Convenient macro allowing to define superbuild arg
  248. #
  249. MACRO(ctk_set_superbuild_boolean_arg ctk_cmake_var)
  250. SET(superbuild_${ctk_cmake_var} ON)
  251. IF(DEFINED ${ctk_cmake_var} AND NOT ${ctk_cmake_var})
  252. SET(superbuild_${ctk_cmake_var} OFF)
  253. ENDIF()
  254. ENDMACRO()
  255. #-----------------------------------------------------------------------------
  256. # Set superbuild boolean args
  257. #
  258. SET(ctk_cmake_boolean_args
  259. BUILD_TESTING
  260. CTK_USE_KWSTYLE
  261. ${ctk_libs_bool_vars}
  262. ${ctk_plugins_bool_vars}
  263. ${ctk_applications_bool_vars}
  264. )
  265. SET(ctk_superbuild_boolean_args)
  266. FOREACH(ctk_cmake_arg ${ctk_cmake_boolean_args})
  267. ctk_set_superbuild_boolean_arg(${ctk_cmake_arg})
  268. LIST(APPEND ctk_superbuild_boolean_args -D${ctk_cmake_arg}:BOOL=${superbuild_${ctk_cmake_arg}})
  269. ENDFOREACH()
  270. #-----------------------------------------------------------------------------
  271. # CTK Configure
  272. #
  273. SET(proj CTK-Configure)
  274. ExternalProject_Add(${proj}
  275. DOWNLOAD_COMMAND ""
  276. CMAKE_GENERATOR ${gen}
  277. CMAKE_ARGS
  278. ${ctk_superbuild_boolean_args}
  279. -DCTK_SUPERBUILD:BOOL=OFF
  280. -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}
  281. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  282. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  283. -DCMAKE_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
  284. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  285. -DCTK_KWSTYLE_EXECUTABLE:FILEPATH=${CTK_KWSTYLE_EXECUTABLE}
  286. -DDCMTK_DIR=${DCMTK_DIR} # FindDCMTK expects DCMTK_DIR
  287. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  288. BINARY_DIR ${CMAKE_BINARY_DIR}/CTK-build
  289. BUILD_COMMAND ""
  290. INSTALL_COMMAND ""
  291. DEPENDS
  292. "CTK-Utilities"
  293. )
  294. #-----------------------------------------------------------------------------
  295. # CTK
  296. #
  297. #MESSAGE(STATUS SUPERBUILD_EXCLUDE_CTKBUILD_TARGET:${SUPERBUILD_EXCLUDE_CTKBUILD_TARGET})
  298. IF(NOT DEFINED SUPERBUILD_EXCLUDE_CTKBUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_CTKBUILD_TARGET)
  299. SET(proj CTK-build)
  300. ExternalProject_Add(${proj}
  301. DOWNLOAD_COMMAND ""
  302. CMAKE_GENERATOR ${gen}
  303. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  304. BINARY_DIR CTK-build
  305. INSTALL_COMMAND ""
  306. DEPENDS
  307. "CTK-Configure"
  308. )
  309. ENDIF()
  310. #-----------------------------------------------------------------------------
  311. # Custom target allowing to drive the build of CTK project itself
  312. #
  313. ADD_CUSTOM_TARGET(CTK
  314. COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
  315. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
  316. )