summaryrefslogtreecommitdiffstats
path: root/Tests/ExternalProject/CMakeLists.txt
blob: 7d857a3ef1ded73e1cd66241d42d1c3500076c12 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
cmake_minimum_required(VERSION 2.6)
project(ExternalProjectTest NONE)

include(ExternalProject)

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

# Use a "TryCheckout" technique on small subtrees of certain projects
# to see if cvs checkout and svn checkout may be used on this machine
# without problems. If so, we can test the projects that use those
# download techniques. If not, we skip them on this machine...
#
include("${CMAKE_CURRENT_SOURCE_DIR}/TryCheckout.cmake")

if(NOT DEFINED can_build_kwstyle)
  if(WATCOM)
    set(can_build_kwstyle 0)
  else()
    set(can_build_kwstyle 1)
  endif()
endif()

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")
    string(LENGTH "${binary_base}/TutorialStep5-Local" n)
    if(n GREATER 72)
      set(can_build_tutorial_step5 0)
    endif()
  endif()
endif()

if(NOT DEFINED can_use_cvs)
  try_cvs_checkout(
    ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
    "CMake/Tests/Tutorial/Step1"
    "${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/TutorialStep1"
    can_use_cvs
    )
  set(can_use_cvs ${can_use_cvs} CACHE STRING "Was try_cvs_checkout successful?")
endif()

if(NOT DEFINED can_use_svn)
  try_svn_checkout(
    "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
    "${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/gdcmmd5"
    can_use_svn
    )
  set(can_use_svn ${can_use_svn} CACHE STRING "Was try_svn_checkout successful?")
endif()

message(STATUS "can_build_kwstyle='${can_build_kwstyle}'")
message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'")
message(STATUS "can_use_cvs='${can_use_cvs}'")
message(STATUS "can_use_svn='${can_use_svn}'")


# Empty projects that test all the known ep_add argument key words:
#
set(proj MinimalNoOpProject)
ep_add(${proj}
  BUILD_COMMAND ""
  CONFIGURE_COMMAND ""
  DOWNLOAD_COMMAND ""
  INSTALL_COMMAND ""
)

set(proj EmptyNoOpProject)
ep_add(${proj}
  BUILD_COMMAND ""
  CMAKE_ARGS ""
  CONFIGURE_COMMAND ""
  CVS_REPOSITORY ""
  CVS_MODULE ""
  CVS_TAG ""
  DEPENDS "MinimalNoOpProject"
  DOWNLOAD_COMMAND ""
  INSTALL_COMMAND ""
  PATCH_COMMAND ""
  SVN_REPOSITORY ""
  SVN_TAG ""
  URL ""
  UPDATE_COMMAND ""
)


# Local DIR:
#
if(can_build_tutorial_step5)
  set(proj TutorialStep5-Local)
  ep_add(${proj}
    URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
  )
  ep_get(${proj} install_dir)
  set(TutorialStep5_install_dir ${install_dir})
endif()


# Local TAR:
#
set(proj TutorialStep1-LocalTAR)
ep_add(${proj}
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
  LIST_SEPARATOR ::
  PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
  CMAKE_GENERATOR "${CMAKE_GENERATOR}"
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
             -DTEST_LIST:STRING=A::B::C
  INSTALL_COMMAND ""
)

set(proj TutorialStep1-LocalNoDirTAR)
ep_add(${proj}
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar"
  LIST_SEPARATOR @@
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
             -DTEST_LIST:STRING=1@@2@@3
  INSTALL_COMMAND ""
)
ep_add_step(${proj} mypatch
  COMMAND ${CMAKE_COMMAND} -E echo "This is a custom external project step."
  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
  WORKING_DIRECTORY <SOURCE_DIR>
  DEPENDEES download
  DEPENDERS configure
  )


# Local TGZ:
#
set(proj TutorialStep1-LocalTGZ)
ep_add(${proj}
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz"
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
  INSTALL_COMMAND ""
)

set(proj TutorialStep1-LocalNoDirTGZ)
ep_add(${proj}
  URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
  CMAKE_GENERATOR "${CMAKE_GENERATOR}"
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
  INSTALL_COMMAND ""
)


# Download TAR:
#
# TODO: Add a remote .tar file


# Download TGZ:
#
# TODO: Add a remote .tgz file


# Download CVS:
#
if(can_use_cvs)
  # CVS by date stamp:
  #
  set(proj TutorialStep1-20081201)
  ep_add(${proj}
    CVS_REPOSITORY ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
    CVS_MODULE "CMake/Tests/Tutorial/Step1"
    CVS_TAG "-D2008-12-01 01:00:00 UTC"
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
    INSTALL_COMMAND ""
  )

  # CVS by tag:
  #
  set(proj kwsys-from-CMake-2-6-2)
  ep_add(${proj}
    CVS_REPOSITORY ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
    CVS_MODULE "CMake/Source/kwsys"
    CVS_TAG -rCMake-2-6-2
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
    INSTALL_COMMAND ""
  )

  if(can_build_kwstyle)
    # Live CVS / HEAD (no CVS_TAG):
    #
    set(proj KWStyle-CVSHEAD)
    ep_add(${proj}
      CVS_REPOSITORY ":pserver:anoncvs@public.kitware.com:/cvsroot/KWStyle"
      CVS_MODULE "KWStyle"
      CMAKE_GENERATOR "${CMAKE_GENERATOR}"
      CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
      DEPENDS "EmptyNoOpProject"
      DEPENDS "TutorialStep1-LocalTAR"
      DEPENDS "TutorialStep1-LocalNoDirTAR"
      DEPENDS "TutorialStep1-LocalTGZ"
      DEPENDS "TutorialStep1-LocalNoDirTGZ"
      DEPENDS "TutorialStep1-20081201"
      DEPENDS "kwsys-from-CMake-2-6-2"
    )
    ep_get(${proj} source_dir install_dir)
    set(kwstyle_source_dir ${source_dir})
    set(kwstyle_install_dir ${install_dir})
  endif()
endif()


# Download SVN:
#
if(can_use_svn)
  # SVN by date stamp:
  #
  set(proj gdcm-md5-20081204)
  ep_add(${proj}
    SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
    SVN_TAG "-r{2008-12-04 01:00:00 +0000}"
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
  )
  ep_get(${proj} install_dir)
  set(gdcm_install_dir ${install_dir})

  # SVN by revision number:
  #
  set(proj gdcm-md5-r4824)
  ep_add(${proj}
    SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
    SVN_TAG "-r4824"
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
    INSTALL_COMMAND ""
  )

  # Live SVN / trunk (no SVN_TAG):
  #
  set(proj gdcm-md5-SVNtrunk)
  ep_add(${proj}
    SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
    INSTALL_COMMAND ""
  )
endif()


# Test the testable built/installed products:
#
enable_testing()


# Use these as input to the KWStyle tests:
#
set(kwstyleXmlFile "${kwstyle_source_dir}/Testing/Data/0001-KWStyleConfiguration.kws.xml")
set(header "${TutorialStep5_install_dir}/include/TutorialConfig.h")


# Do at least a smoke test of a built executable from each
# project's build directory...
#
# BuildTree tests:
#
if(can_build_tutorial_step5)
  add_test(TutorialStep5-Local-BuildTreeTest
    "${binary_base}/TutorialStep5-Local/Tutorial" 42)
endif()

add_test(TutorialStep1-LocalTAR-BuildTreeTest
  "${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36)

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

add_test(TutorialStep1-LocalTGZ-BuildTreeTest
  "${binary_base}/TutorialStep1-LocalTGZ/Tutorial" 16)

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

if(can_use_cvs)
  add_test(TutorialStep1-20081201-BuildTreeTest
    "${binary_base}/TutorialStep1-20081201/Tutorial" 4)

  add_test(kwsys-from-CMake-2-6-2-BuildTreeTest
    "${binary_base}/kwsys-from-CMake-2-6-2/kwsysTestProcess" 1)

  if(can_build_kwstyle)
    add_test(KWStyle-CVSHEAD-BuildTreeTest
      "${binary_base}/KWStyle-CVSHEAD/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
  endif()
endif()

if(can_use_svn)
  add_test(gdcm-md5-20081204-BuildTreeTest
    "${binary_base}/gdcm-md5-20081204/md5main" --version)

  add_test(gdcm-md5-r4824-BuildTreeTest
    "${binary_base}/gdcm-md5-r4824/md5main" --version)

  add_test(gdcm-md5-SVNtrunk-BuildTreeTest
    "${binary_base}/gdcm-md5-SVNtrunk/md5main" --version)
endif()


# InstallTree tests:
#
if(can_build_tutorial_step5)
  add_test(TutorialStep5-InstallTreeTest
    "${TutorialStep5_install_dir}/bin/Tutorial" 49)
endif()

if(can_use_cvs)
  if(can_build_kwstyle)
    add_test(KWStyle-InstallTreeTest
      "${kwstyle_install_dir}/bin/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
  endif()
endif()

if(can_use_svn)
  add_test(gdcm-md5-InstallTreeTest
    "${gdcm_install_dir}/bin/md5main" --version)
endif()