blob: 6f8a7b15bc332fbb3ac158678a5e61f1c0a8c77c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
cmake_minimum_required(VERSION 2.8.12)
project(ExternalProjectUpdateTest NONE)
if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12)
cmake_policy(SET CMP0114 NEW)
else()
# This test is very noisy with warnings about this policy if we don't
# explicitly set it. Projects shouldn't do this, but for test code this
# is reasonable.
cmake_policy(SET CMP0114 OLD)
endif()
cmake_policy(GET CMP0114 cmp0114)
include(ExternalProject)
find_package(Git)
option(ExternalProjectUpdateTest_USE_FOLDERS "Enable folder grouping in IDEs." ON)
if(ExternalProjectUpdateTest_USE_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
else()
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
endif()
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER
"CMakePredefinedTargets-in-ExternalProjectUpdateTest")
set(base "${CMAKE_BINARY_DIR}/CMakeExternals")
set(binary_base "${base}/Build")
set_property(DIRECTORY PROPERTY EP_BASE ${base})
if(cmp0114 STREQUAL "NEW")
set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test update)
set(TestUpdateCommand_STEP_TARGETS STEP_TARGETS update)
set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS)
else()
set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update)
set(TestUpdateCommand_STEP_TARGETS)
set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS INDEPENDENT_STEP_TARGETS update)
endif()
ExternalProject_Add(TestUpdateCommand
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
UPDATE_COMMAND ${CMAKE_COMMAND} -E echo update
UPDATE_DISCONNECTED 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
${TestUpdateCommand_STEP_TARGETS}
${TestUpdateCommand_INDEPENDENT_STEP_TARGETS}
)
add_custom_target(TestUpdateCommandDriver ALL)
add_dependencies(TestUpdateCommandDriver TestUpdateCommand-update)
set(do_git_tests 0)
if(GIT_EXECUTABLE)
set(do_git_tests 1)
message(STATUS "GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
if("${GIT_VERSION_STRING}" VERSION_LESS 1.6.5)
message(STATUS "No ExternalProject git tests with git client less than version 1.6.5")
set(do_git_tests 0)
endif()
endif()
# This should be specified from the command line.
if(NOT TEST_GIT_TAG)
set(TEST_GIT_TAG origin/master)
endif()
if(do_git_tests)
set(local_git_repo "../../LocalRepositories/GIT")
# Unzip/untar the git repository in our source folder so that other
# projects below may use it to test git args of ExternalProject_Add
#
set(proj SetupLocalGITRepository)
ExternalProject_Add(${proj}
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT
URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz
BUILD_COMMAND ""
CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version
INSTALL_COMMAND ""
)
set_property(TARGET ${proj}
PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing")
set(proj TutorialStep1-GIT)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_TAG ${TEST_GIT_TAG}
GIT_CONFIG "user.email=testauthor@cmake.org"
"user.name=testauthor"
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ""
)
ExternalProject_Add_StepDependencies(${proj} download SetupLocalGITRepository)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
set(proj TutorialStep2-GIT)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_TAG ${TEST_GIT_TAG}
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ""
UPDATE_DISCONNECTED 1
)
ExternalProject_Add_StepDependencies(${proj} download SetupLocalGITRepository)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
endif()
# Test the testable built/installed products:
#
enable_testing()
# Do at least a smoke test of a built executable from each
# project's build directory...
#
# BuildTree tests:
#
if(do_git_tests)
add_test(TutorialStep1-GIT
"${binary_base}/TutorialStep1-GIT/Tutorial" 81)
endif()
message(STATUS "do_git_tests='${do_git_tests}'")
message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
|