SuperBuild.cmake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #-----------------------------------------------------------------------------
  21. # WARNING - No change should be required after this comment
  22. # when you are adding a new external project dependency.
  23. #-----------------------------------------------------------------------------
  24. #-----------------------------------------------------------------------------
  25. # Make sure ${CTK_BINARY_DIR}/CTK-build/bin exists
  26. # May be used by some external project to install libs
  27. if(NOT EXISTS ${CTK_BINARY_DIR}/CTK-build/bin)
  28. file(MAKE_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
  29. endif()
  30. #-----------------------------------------------------------------------------
  31. set(proj CTK)
  32. set(ep_cxx_standard_arg)
  33. if(CMAKE_CXX_STANDARD)
  34. set(ep_cxx_standard_arg "-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}")
  35. endif()
  36. ExternalProject_Add(${proj}
  37. ${${proj}_EP_ARGS}
  38. DOWNLOAD_COMMAND ""
  39. CMAKE_CACHE_ARGS
  40. -DCTK_SUPERBUILD:BOOL=OFF
  41. -DCTK_SUPERBUILD_BINARY_DIR:PATH=${CTK_BINARY_DIR}
  42. -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
  43. -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
  44. -DCMAKE_CXX_FLAGS_INIT:STRING=${CMAKE_CXX_FLAGS_INIT}
  45. -DCMAKE_C_FLAGS_INIT:STRING=${CMAKE_C_FLAGS_INIT}
  46. -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  47. -DCMAKE_MACOSX_RPATH:BOOL=${CMAKE_MACOSX_RPATH}
  48. ${ep_cxx_standard_arg}
  49. SOURCE_DIR ${CTK_SOURCE_DIR}
  50. BINARY_DIR ${CTK_BINARY_DIR}/CTK-build
  51. INSTALL_COMMAND ""
  52. DEPENDS
  53. ${CTK_DEPENDENCIES}
  54. STEP_TARGETS configure
  55. )
  56. # This custom external project step forces the build and later
  57. # steps to run whenever a top level build is done...
  58. #
  59. # BUILD_ALWAYS flag is available in CMake 3.1 that allows force build
  60. # of external projects without this workaround. Remove this workaround
  61. # and use the CMake flag instead, when CTK's required minimum CMake
  62. # version will be at least 3.1.
  63. #
  64. if(CMAKE_CONFIGURATION_TYPES)
  65. set(BUILD_STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-stamp/${CMAKE_CFG_INTDIR}/${proj}-build")
  66. else()
  67. set(BUILD_STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-stamp/${proj}-build")
  68. endif()
  69. ExternalProject_Add_Step(${proj} forcebuild
  70. COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_STAMP_FILE}
  71. COMMENT "Forcing build step for '${proj}'"
  72. DEPENDEES build
  73. ALWAYS 1
  74. )