CMakeLists.txt 10.4 KB
Newer Older
1
2
3
cmake_minimum_required(VERSION 2.6)
project(ExternalProjectTest NONE)

4
include(ExternalProject)
5

6
7
8
find_package(CVS)
find_package(Subversion)

9
10
11
set(base "${CMAKE_BINARY_DIR}/CMakeExternals")
set(binary_base "${base}/Build")
set_property(DIRECTORY PROPERTY EP_BASE ${base})
12

13
14
15
16
17
18
19
20
21
if(NOT DEFINED can_build_tutorial_step5)
  set(can_build_tutorial_step5 1)

  # Tutorial Step5 cannot build correctly using Visual Studio 6
  # on Windows 98 if the path of its build tree exceeds 72
  # characters in length... So don't attempt to build it
  # in a long path on Win98:
  #
  if(CMAKE_SYSTEM STREQUAL "Windows-4.10")
22
    string(LENGTH "${binary_base}/TutorialStep5-Local" n)
23
24
25
26
    if(n GREATER 72)
      set(can_build_tutorial_step5 0)
    endif()
  endif()
27
28
29
30
31
32
33
34
35
36
37

  # The ExternalProject builds of Tutorial Step5 cannot be built
  # correctly 2nd and later times in an in-source build...
  # (because the CMakeCache.txt from the real in-source build of
  # the Tests/Tutorial/Step5 directory gets copied when we do
  # the "source directory copy" step... but it still refers to
  # its original path which yields a configure error.) So:
  #
  if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
    set(can_build_tutorial_step5 0)
  endif()
38
39
40
endif()

message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'")
41
42


43
# Empty projects that test all the known ExternalProject_Add argument key words:
44
45
#
set(proj MinimalNoOpProject)
46
ExternalProject_Add(${proj}
47
48
49
50
51
52
53
  BUILD_COMMAND ""
  CONFIGURE_COMMAND ""
  DOWNLOAD_COMMAND ""
  INSTALL_COMMAND ""
)

set(proj EmptyNoOpProject)
54
ExternalProject_Add(${proj}
55
  BUILD_COMMAND ""
56
  CMAKE_ARGS ""
57
58
59
60
61
62
63
  CONFIGURE_COMMAND ""
  CVS_REPOSITORY ""
  CVS_MODULE ""
  CVS_TAG ""
  DEPENDS "MinimalNoOpProject"
  DOWNLOAD_COMMAND ""
  INSTALL_COMMAND ""
64
  PATCH_COMMAND ""
65
  SVN_REPOSITORY ""
66
67
  SVN_REVISION ""
  TEST_COMMAND ""
68
  URL ""
69
  UPDATE_COMMAND ""
70
71
72
)


73
74
# Local DIR:
#
75
76
if(can_build_tutorial_step5)
  set(proj TutorialStep5-Local)
77
  ExternalProject_Add(${proj}
78
79
    URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
80
    TEST_BEFORE_INSTALL 1
81
  )
82
  ExternalProject_Get_Property(${proj} install_dir)
83
  set(TutorialStep5_install_dir ${install_dir})
84
85

  set(proj TutorialStep5-Local-TestAfterInstall)
86
  ExternalProject_Add(${proj}
87
88
89
90
    URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
    TEST_AFTER_INSTALL 1
  )
91
endif()
92
93
94
95
96


# Local TAR:
#
set(proj TutorialStep1-LocalTAR)
97
ExternalProject_Add(${proj}
98
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
99
  LIST_SEPARATOR ::
100
  PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
101
  CMAKE_GENERATOR "${CMAKE_GENERATOR}"
102
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
103
             -DTEST_LIST:STRING=A::B::C
104
105
106
107
  INSTALL_COMMAND ""
)

set(proj TutorialStep1-LocalNoDirTAR)
108
ExternalProject_Add(${proj}
109
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar"
110
  LIST_SEPARATOR @@
111
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
112
             -DTEST_LIST:STRING=1@@2@@3
113
114
  INSTALL_COMMAND ""
)
115
ExternalProject_Add_Step(${proj} mypatch
116
117
  COMMAND ${CMAKE_COMMAND} -E echo "This is a custom external project step."
  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
118
  WORKING_DIRECTORY <SOURCE_DIR>
119
120
121
  DEPENDEES download
  DEPENDERS configure
  )
122
123
124
125
126


# Local TGZ:
#
set(proj TutorialStep1-LocalTGZ)
127
ExternalProject_Add(${proj}
128
129
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz"
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
130
131
132
133
  INSTALL_COMMAND ""
)

set(proj TutorialStep1-LocalNoDirTGZ)
134
ExternalProject_Add(${proj}
135
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
136
  CMAKE_GENERATOR "${CMAKE_GENERATOR}"
137
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
138
139
140
141
  INSTALL_COMMAND ""
)


142
143
set(do_cvs_tests 0)

144
if(CVS_EXECUTABLE)
145
146
147
148
149
150
151
152
153
154
155
  set(do_cvs_tests 1)
endif()

if(do_cvs_tests AND NOT UNIX)
  if("${CVS_EXECUTABLE}" MATCHES "cygwin")
    message(STATUS "No ExternalProject cvs tests with cygwin cvs.exe outside cygwin!")
    set(do_cvs_tests 0)
  endif()
endif()

if(do_cvs_tests)
156
  # Unzip/untar the CVS repository in our source folder so that other
157
  # projects below may use it to test CVS args of ExternalProject_Add
158
159
160
  #
  set(proj SetupLocalCVSRepository)
  set(local_cvs_repo "${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/CVS")
161
  ExternalProject_Add(${proj}
162
163
164
165
166
167
168
    SOURCE_DIR ${local_cvs_repo}
    URL ${CMAKE_CURRENT_SOURCE_DIR}/cvsrepo.tgz
    BUILD_COMMAND ""
    CONFIGURE_COMMAND ${CVS_EXECUTABLE} --version
    INSTALL_COMMAND ""
  )

169
170
  # CVS by date stamp:
  #
171
  set(proj TutorialStep1-CVS-20090626)
172
  ExternalProject_Add(${proj}
173
174
    CVS_REPOSITORY "${local_cvs_repo}"
    CVS_MODULE "TutorialStep1"
175
176
    CVS_TAG "-D2009-06-26 16:50:00 UTC"
    UPDATE_COMMAND ""
177
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
178
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
179
    INSTALL_COMMAND ""
180
    DEPENDS "SetupLocalCVSRepository"
181
182
183
184
  )

  # CVS by tag:
  #
185
  set(proj TutorialStep1-CVS-testtag1)
186
  ExternalProject_Add(${proj}
187
188
189
    CVS_REPOSITORY "${local_cvs_repo}"
    CVS_MODULE "TutorialStep1"
    CVS_TAG -rtesttag1
190
    UPDATE_COMMAND ""
191
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
192
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
193
    INSTALL_COMMAND ""
194
    DEPENDS "SetupLocalCVSRepository"
195
196
  )

197
198
199
  # Live CVS / HEAD (no CVS_TAG):
  #
  set(proj TutorialStep1-CVS-HEAD)
200
  ExternalProject_Add(${proj}
201
202
203
204
205
206
207
208
209
210
211
    CVS_REPOSITORY "${local_cvs_repo}"
    CVS_MODULE "TutorialStep1"
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
    INSTALL_COMMAND ""
    DEPENDS "SetupLocalCVSRepository"
    DEPENDS "EmptyNoOpProject"
    DEPENDS "TutorialStep1-LocalTAR"
    DEPENDS "TutorialStep1-LocalNoDirTAR"
    DEPENDS "TutorialStep1-LocalTGZ"
    DEPENDS "TutorialStep1-LocalNoDirTGZ"
212
    DEPENDS "TutorialStep1-CVS-20090626"
213
214
    DEPENDS "TutorialStep1-CVS-testtag1"
  )
215
216
217
endif()


218
219
set(do_svn_tests 0)

220
if(Subversion_SVN_EXECUTABLE)
221
222
223
  set(do_svn_tests 1)
endif()

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Only do svn tests with svn >= version 1.2
#
if(do_svn_tests)
  execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version
    OUTPUT_VARIABLE Subversion_VERSION_SVN
    OUTPUT_STRIP_TRAILING_WHITESPACE)
  string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*"
    "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}")
  message(STATUS "Subversion_VERSION_SVN='${Subversion_VERSION_SVN}'")

  if(Subversion_VERSION_SVN VERSION_LESS 1.2)
    message(STATUS "No ExternalProject svn tests with svn client less than version 1.2")
    set(do_svn_tests 0)
  endif()
endif()

# Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements:
#
if(do_svn_tests)
  if(CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND
     NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin")
    message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build")
    set(do_svn_tests 0)
  endif()
endif()

250
if(do_svn_tests)
251
  # Unzip/untar the SVN repository in our source folder so that other
252
  # projects below may use it to test SVN args of ExternalProject_Add
253
254
255
256
  #
  set(proj SetupLocalSVNRepository)
  set(local_svn_repo "${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/SVN")
  set(local_svn_repo_url "file:///${local_svn_repo}/TutorialStep1")
257
  ExternalProject_Add(${proj}
258
259
260
261
262
263
264
    SOURCE_DIR ${local_svn_repo}
    URL ${CMAKE_CURRENT_SOURCE_DIR}/svnrepo.tgz
    BUILD_COMMAND ""
    CONFIGURE_COMMAND ${Subversion_SVN_EXECUTABLE} --version
    INSTALL_COMMAND ""
  )

265
266
  # SVN by date stamp:
  #
267
  set(proj TutorialStep1-SVN-20090626)
268
  ExternalProject_Add(${proj}
269
    SVN_REPOSITORY "${local_svn_repo_url}"
270
    SVN_REVISION "-r{2009-06-26 16:50:00 +0000}"
271
    UPDATE_COMMAND ""
272
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
273
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
274
275
    INSTALL_COMMAND ""
    DEPENDS "SetupLocalSVNRepository"
276
277
278
279
  )

  # SVN by revision number:
  #
280
  set(proj TutorialStep1-SVN-r2)
281
  ExternalProject_Add(${proj}
282
    SVN_REPOSITORY "${local_svn_repo_url}"
283
    SVN_REVISION "-r2"
284
    UPDATE_COMMAND ""
285
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
286
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
287
    INSTALL_COMMAND ""
288
    DEPENDS "SetupLocalSVNRepository"
289
290
  )

291
  # Live SVN / trunk (no SVN_REVISION):
292
  #
293
  set(proj TutorialStep1-SVN-trunk)
294
  ExternalProject_Add(${proj}
295
    SVN_REPOSITORY "${local_svn_repo_url}"
296
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
297
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
298
    INSTALL_COMMAND ""
299
    DEPENDS "SetupLocalSVNRepository"
300
301
302
303
304
305
306
307
308
309
310
311
312
313
  )
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:
#
314
315
if(can_build_tutorial_step5)
  add_test(TutorialStep5-Local-BuildTreeTest
316
    "${binary_base}/TutorialStep5-Local/Tutorial" 42)
317
318
  set_property(TEST TutorialStep5-Local-BuildTreeTest
    APPEND PROPERTY LABELS Step5 BuildTree)
319
endif()
320
321

add_test(TutorialStep1-LocalTAR-BuildTreeTest
322
  "${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36)
323
324
set_property(TEST TutorialStep1-LocalTAR-BuildTreeTest
  APPEND PROPERTY LABELS TAR)
325
326

add_test(TutorialStep1-LocalNoDirTAR-BuildTreeTest
327
  "${binary_base}/TutorialStep1-LocalNoDirTAR/EP-Tutorial" 25)
328
329

add_test(TutorialStep1-LocalTGZ-BuildTreeTest
330
  "${binary_base}/TutorialStep1-LocalTGZ/Tutorial" 16)
331
332
set_property(TEST TutorialStep1-LocalTGZ-BuildTreeTest
  APPEND PROPERTY LABELS TGZ)
333
334

add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest
335
  "${binary_base}/TutorialStep1-LocalNoDirTGZ/Tutorial" 9)
336

337
if(do_cvs_tests)
338
339
  add_test(TutorialStep1-CVS-20090626-BuildTreeTest
    "${binary_base}/TutorialStep1-CVS-20090626/Tutorial" 4)
340

341
342
  add_test(TutorialStep1-CVS-testtag1-BuildTreeTest
    "${binary_base}/TutorialStep1-CVS-testtag1/Tutorial" 64)
343

344
345
  add_test(TutorialStep1-CVS-HEAD-BuildTreeTest
    "${binary_base}/TutorialStep1-CVS-HEAD/Tutorial" 81)
346
347
endif()

348
if(do_svn_tests)
349
350
  add_test(TutorialStep1-SVN-20090626-BuildTreeTest
    "${binary_base}/TutorialStep1-SVN-20090626/Tutorial" 100)
351

352
353
  add_test(TutorialStep1-SVN-r2-BuildTreeTest
    "${binary_base}/TutorialStep1-SVN-r2/Tutorial" 99)
354

355
356
  add_test(TutorialStep1-SVN-trunk-BuildTreeTest
    "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98)
357
358
359
360
361
endif()


# InstallTree tests:
#
362
363
if(can_build_tutorial_step5)
  add_test(TutorialStep5-InstallTreeTest
364
    "${TutorialStep5_install_dir}/bin/Tutorial" 49)
365
366
  set_property(TEST TutorialStep5-InstallTreeTest
    APPEND PROPERTY LABELS Step5 InstallTree)
367
endif()