SuperBuild.cmake 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. SET(cmake_version_required "2.8")
  2. SET(cmake_version_required_regex "2.8.*")
  3. SET(cmake_version_required_dash "2-8")
  4. IF(NOT CMAKE_VERSION MATCHES "${cmake_version_required_regex}")
  5. SET(err "error: CTK SuperBuild requires CMake version ${cmake_version_required}")
  6. MESSAGE(FATAL_ERROR "${err}")
  7. ENDIF()
  8. CMAKE_MINIMUM_REQUIRED(VERSION ${cmake_version_required})
  9. #
  10. # CTK_QMAKE_EXECUTABLE
  11. # CTK_KWSTYLE_EXECUTABLE
  12. #
  13. #-----------------------------------------------------------------------------
  14. # Enable and setup External project global properties
  15. #
  16. INCLUDE(ExternalProject)
  17. SET(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals")
  18. SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base})
  19. SET(ep_install_dir ${ep_base}/Install)
  20. #SET(ep_build_dir ${ep_base}/Build)
  21. #SET(ep_parallelism_level)
  22. SET(ep_build_shared_libs ON)
  23. SET(ep_build_testing OFF)
  24. SET(ep_common_args
  25. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  26. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  27. -DBUILD_TESTING:BOOL=${ep_build_testing}
  28. )
  29. # Compute -G arg for configuring external projects with the same CMake generator:
  30. IF(CMAKE_EXTRA_GENERATOR)
  31. SET(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
  32. ELSE()
  33. SET(gen "${CMAKE_GENERATOR}")
  34. ENDIF()
  35. # Use this value where semi-colons are needed in ep_add args:
  36. set(sep "^^")
  37. #-----------------------------------------------------------------------------
  38. # Update CMake module path
  39. #
  40. SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
  41. #-----------------------------------------------------------------------------
  42. # Qt is expected to be setup by CTK/CMakeLists.txt just before it includes the SuperBuild script
  43. #
  44. #-----------------------------------------------------------------------------
  45. # KWStyle
  46. #
  47. SET (kwstyle_DEPENDS)
  48. IF (CTK_USE_KWSTYLE)
  49. IF (NOT DEFINED CTK_KWSTYLE_EXECUTABLE)
  50. SET(proj KWStyle-CVSHEAD)
  51. SET(kwstyle_DEPENDS ${proj})
  52. ExternalProject_Add(${proj}
  53. LIST_SEPARATOR ${sep}
  54. CVS_REPOSITORY ":pserver:anoncvs:@public.kitware.com:/cvsroot/KWStyle"
  55. CVS_MODULE "KWStyle"
  56. CMAKE_GENERATOR ${gen}
  57. CMAKE_ARGS
  58. ${ep_common_args}
  59. )
  60. SET(CTK_KWSTYLE_EXECUTABLE ${ep_install_dir}/bin/KWStyle)
  61. ENDIF()
  62. ENDIF()
  63. #-----------------------------------------------------------------------------
  64. # Utilities/DCMTK
  65. #
  66. SET(proj DCMTK)
  67. ExternalProject_Add(${proj}
  68. DOWNLOAD_COMMAND ""
  69. INSTALL_COMMAND "" # TODO DCMTK should be installable
  70. CMAKE_GENERATOR ${gen}
  71. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/DCMTK
  72. CMAKE_ARGS
  73. ${ep_common_args}
  74. )
  75. #-----------------------------------------------------------------------------
  76. # CTK Utilities
  77. #
  78. set(proj CTK-Utilities)
  79. ExternalProject_Add(${proj}
  80. DOWNLOAD_COMMAND ""
  81. CONFIGURE_COMMAND ""
  82. BUILD_COMMAND ""
  83. INSTALL_COMMAND ""
  84. DEPENDS
  85. ${kwstyle_DEPENDS}
  86. "DCMTK"
  87. )
  88. #-----------------------------------------------------------------------------
  89. # Convenient macro allowing to define superbuild arg
  90. #
  91. MACRO(ctk_set_superbuild_boolean_arg ctk_cmake_var)
  92. SET(superbuild_${ctk_cmake_var} ON)
  93. IF(DEFINED ${ctk_cmake_var} AND NOT ${ctk_cmake_var})
  94. SET(superbuild_${ctk_cmake_var} OFF)
  95. ENDIF()
  96. SET(superbuild_ep_arg_${ctk_cmake_var} -D${ctk_cmake_arg}:BOOL=${superbuild_${ctk_cmake_var}})
  97. ENDMACRO()
  98. #-----------------------------------------------------------------------------
  99. # Set superbuild boolean args
  100. #
  101. SET(ctk_cmake_boolean_args
  102. BUILD_TESTING
  103. CTK_USE_KWSTYLE
  104. ${ctk_libs}
  105. )
  106. SET(ctk_superbuild_boolean_args)
  107. FOREACH(ctk_cmake_arg ${ctk_cmake_boolean_args})
  108. ctk_set_superbuild_boolean_arg(${ctk_cmake_arg})
  109. LIST(APPEND ctk_superbuild_boolean_args -D${ctk_cmake_arg}:BOOL=${superbuild_${ctk_cmake_arg}})
  110. ENDFOREACH()
  111. #-----------------------------------------------------------------------------
  112. # CTK Configure
  113. #
  114. SET(proj CTK-Configure)
  115. ExternalProject_Add(${proj}
  116. DOWNLOAD_COMMAND ""
  117. CMAKE_GENERATOR ${gen}
  118. CMAKE_ARGS
  119. ${ctk_superbuild_boolean_args}
  120. -DCTK_SUPERBUILD:BOOL=OFF
  121. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  122. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  123. -DCTK_QMAKE_EXECUTABLE:FILEPATH=${CTK_QMAKE_EXECUTABLE}
  124. -DCTK_KWSTYLE_EXECUTABLE:FILEPATH=${CTK_KWSTYLE_EXECUTABLE}
  125. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  126. BINARY_DIR ${CMAKE_BINARY_DIR}/CTK-build
  127. BUILD_COMMAND ""
  128. INSTALL_COMMAND ""
  129. DEPENDS
  130. "CTK-Utilities"
  131. )
  132. #-----------------------------------------------------------------------------
  133. # CTK
  134. #
  135. set(proj CTK-build)
  136. ExternalProject_Add(${proj}
  137. DOWNLOAD_COMMAND ""
  138. CMAKE_GENERATOR ${gen}
  139. SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
  140. BINARY_DIR CTK-build
  141. #BUILD_COMMAND ""
  142. INSTALL_COMMAND ""
  143. DEPENDS
  144. "CTK-Configure"
  145. )