SuperBuild.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. ExternalProject_Add(${proj}
  33. ${${proj}_EP_ARGS}
  34. DOWNLOAD_COMMAND ""
  35. CMAKE_CACHE_ARGS
  36. -DCTK_SUPERBUILD:BOOL=OFF
  37. -DCTK_SUPERBUILD_BINARY_DIR:PATH=${CTK_BINARY_DIR}
  38. -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
  39. -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
  40. -DCMAKE_CXX_FLAGS_INIT:STRING=${CMAKE_CXX_FLAGS_INIT}
  41. -DCMAKE_C_FLAGS_INIT:STRING=${CMAKE_C_FLAGS_INIT}
  42. -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  43. SOURCE_DIR ${CTK_SOURCE_DIR}
  44. BINARY_DIR ${CTK_BINARY_DIR}/CTK-build
  45. INSTALL_COMMAND ""
  46. DEPENDS
  47. ${CTK_DEPENDENCIES}
  48. STEP_TARGETS configure
  49. )
  50. # This custom external project step forces the build and later
  51. # steps to run whenever a top level build is done...
  52. #
  53. # BUILD_ALWAYS flag is available in CMake 3.1 that allows force build
  54. # of external projects without this workaround. Remove this workaround
  55. # and use the CMake flag instead, when CTK's required minimum CMake
  56. # version will be at least 3.1.
  57. #
  58. if(CMAKE_CONFIGURATION_TYPES)
  59. set(BUILD_STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-stamp/${CMAKE_CFG_INTDIR}/${proj}-build")
  60. else()
  61. set(BUILD_STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-stamp/${proj}-build")
  62. endif()
  63. ExternalProject_Add_Step(${proj} forcebuild
  64. COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_STAMP_FILE}
  65. COMMENT "Forcing build step for '${proj}'"
  66. DEPENDEES build
  67. ALWAYS 1
  68. )