SuperBuild.cmake 11 KB

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