CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. cmake_minimum_required(VERSION 2.8)
  2. project(ExternalProjectUpdateTest NONE)
  3. include(ExternalProject)
  4. find_package(Git)
  5. option(ExternalProjectUpdateTest_USE_FOLDERS "Enable folder grouping in IDEs." ON)
  6. if(ExternalProjectUpdateTest_USE_FOLDERS)
  7. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  8. else()
  9. set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
  10. endif()
  11. set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER
  12. "CMakePredefinedTargets-in-ExternalProjectUpdateTest")
  13. set(base "${CMAKE_BINARY_DIR}/CMakeExternals")
  14. set(binary_base "${base}/Build")
  15. set_property(DIRECTORY PROPERTY EP_BASE ${base})
  16. set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
  17. set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update)
  18. set(do_git_tests 0)
  19. if(GIT_EXECUTABLE)
  20. set(do_git_tests 1)
  21. execute_process(
  22. COMMAND "${GIT_EXECUTABLE}" --version
  23. OUTPUT_VARIABLE ov
  24. OUTPUT_STRIP_TRAILING_WHITESPACE
  25. )
  26. string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}")
  27. message(STATUS "git_version='${git_version}'")
  28. if(git_version VERSION_LESS 1.6.5)
  29. message(STATUS "No ExternalProject git tests with git client less than version 1.6.5")
  30. set(do_git_tests 0)
  31. endif()
  32. endif()
  33. # This should be specified from the command line.
  34. if(NOT TEST_GIT_TAG)
  35. set(TEST_GIT_TAG origin/master)
  36. endif()
  37. if(do_git_tests)
  38. set(local_git_repo "../../LocalRepositories/GIT")
  39. # Unzip/untar the git repository in our source folder so that other
  40. # projects below may use it to test git args of ExternalProject_Add
  41. #
  42. set(proj SetupLocalGITRepository)
  43. ExternalProject_Add(${proj}
  44. SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT
  45. URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz
  46. BUILD_COMMAND ""
  47. CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version
  48. INSTALL_COMMAND ""
  49. )
  50. set_property(TARGET ${proj}
  51. PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing")
  52. set(proj TutorialStep1-GIT)
  53. ExternalProject_Add(${proj}
  54. GIT_REPOSITORY "${local_git_repo}"
  55. GIT_TAG ${TEST_GIT_TAG}
  56. CMAKE_GENERATOR "${CMAKE_GENERATOR}"
  57. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
  58. INSTALL_COMMAND ""
  59. )
  60. ExternalProject_Add_StepDependencies(${proj} download SetupLocalGITRepository)
  61. set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
  62. set(proj TutorialStep2-GIT)
  63. ExternalProject_Add(${proj}
  64. GIT_REPOSITORY "${local_git_repo}"
  65. GIT_TAG ${TEST_GIT_TAG}
  66. CMAKE_GENERATOR "${CMAKE_GENERATOR}"
  67. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
  68. INSTALL_COMMAND ""
  69. UPDATE_DISCONNECTED 1
  70. )
  71. ExternalProject_Add_StepDependencies(${proj} download SetupLocalGITRepository)
  72. set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
  73. endif()
  74. # Test the testable built/installed products:
  75. #
  76. enable_testing()
  77. # Do at least a smoke test of a built executable from each
  78. # project's build directory...
  79. #
  80. # BuildTree tests:
  81. #
  82. if(do_git_tests)
  83. add_test(TutorialStep1-GIT
  84. "${binary_base}/TutorialStep1-GIT/Tutorial" 81)
  85. endif()
  86. message(STATUS "do_git_tests='${do_git_tests}'")
  87. message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'")