ENH: use .exe on vms
[cmake.git] / Tests / ExternalProject / CMakeLists.txt
blob63ab7ef536a62d6f1c0ef292763534e59ac298a2
1 cmake_minimum_required(VERSION 2.6)
2 project(ExternalProjectTest NONE)
4 include(AddExternalProject)
6 get_external_project_directories(base_dir build_dir downloads_dir install_dir
7   sentinels_dir source_dir tmp_dir)
9 set(prefix "${install_dir}")
12 # Use a "TryCheckout" technique on small subtrees of certain projects
13 # to see if cvs checkout and svn checkout may be used on this machine
14 # without problems. If so, we can test the projects that use those
15 # download techniques. If not, we skip them on this machine...
17 include("${CMAKE_CURRENT_SOURCE_DIR}/TryCheckout.cmake")
19 if(NOT DEFINED can_build_kwstyle)
20   if(WATCOM)
21     set(can_build_kwstyle 0)
22   else()
23     set(can_build_kwstyle 1)
24   endif()
25 endif()
27 if(NOT DEFINED can_build_tutorial_step5)
28   set(can_build_tutorial_step5 1)
30   # Tutorial Step5 cannot build correctly using Visual Studio 6
31   # on Windows 98 if the path of its build tree exceeds 72
32   # characters in length... So don't attempt to build it
33   # in a long path on Win98:
34   #
35   if(CMAKE_SYSTEM STREQUAL "Windows-4.10")
36     string(LENGTH "${build_dir}/TutorialStep5-Local" n)
37     if(n GREATER 72)
38       set(can_build_tutorial_step5 0)
39     endif()
40   endif()
41 endif()
43 if(NOT DEFINED can_use_cvs)
44   try_cvs_checkout(
45     ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
46     "CMake/Tests/Tutorial/Step1"
47     "${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/TutorialStep1"
48     can_use_cvs
49     )
50   set(can_use_cvs ${can_use_cvs} CACHE STRING "Was try_cvs_checkout successful?")
51 endif()
53 if(NOT DEFINED can_use_svn)
54   try_svn_checkout(
55     "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
56     "${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/gdcmmd5"
57     can_use_svn
58     )
59   set(can_use_svn ${can_use_svn} CACHE STRING "Was try_svn_checkout successful?")
60 endif()
62 message(STATUS "can_build_kwstyle='${can_build_kwstyle}'")
63 message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'")
64 message(STATUS "can_use_cvs='${can_use_cvs}'")
65 message(STATUS "can_use_svn='${can_use_svn}'")
68 # Empty projects that test all the known add_external_project argument key words:
70 set(proj MinimalNoOpProject)
71 add_external_project(${proj}
72   BUILD_COMMAND ""
73   CONFIGURE_COMMAND ""
74   DOWNLOAD_COMMAND ""
75   INSTALL_COMMAND ""
78 set(proj EmptyNoOpProject)
79 add_external_project(${proj}
80   BUILD_ARGS ""
81   BUILD_COMMAND ""
82   CMAKE_ARGS ""
83   CONFIGURE_COMMAND ""
84   CONFIGURE_DIR ""
85   CVS_REPOSITORY ""
86   CVS_MODULE ""
87   CVS_TAG ""
88   DEPENDS "MinimalNoOpProject"
89   DIR ""
90   DOWNLOAD_COMMAND ""
91   INSTALL_ARGS ""
92   INSTALL_COMMAND ""
93   PATCH_COMMAND ""
94   SVN_REPOSITORY ""
95   SVN_TAG ""
96   TAR ""
97   TAR_URL ""
98   TGZ ""
99   TGZ_URL ""
100   UPDATE_COMMAND ""
104 # Local DIR:
106 if(can_build_tutorial_step5)
107   set(proj TutorialStep5-Local)
108   add_external_project(${proj}
109     DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
110     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix} -G ${CMAKE_GENERATOR} ${source_dir}/${proj}
111   )
112 endif()
115 # Local TAR:
117 set(proj TutorialStep1-LocalTAR)
118 add_external_project(${proj}
119   TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
120   LIST_SEPARATOR ::
121   PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
122   CMAKE_GENERATOR "${CMAKE_GENERATOR}"
123   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
124              -DTEST_LIST:STRING=A::B::C
125   INSTALL_COMMAND ""
128 set(proj TutorialStep1-LocalNoDirTAR)
129 add_external_project(${proj}
130   TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar"
131   LIST_SEPARATOR @@
132   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix} -G ${CMAKE_GENERATOR} ${source_dir}/${proj}
133              -DTEST_LIST:STRING=1@@2@@3
134   INSTALL_COMMAND ""
136 add_external_project_step(${proj} mypatch
137   COMMAND ${CMAKE_COMMAND} -E echo "This is a custom external project step."
138   COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
139   WORKING_DIRECTORY ${source_dir}/TutorialStep1-LocalNoDirTAR
140   DEPENDEES download
141   DEPENDERS configure
142   )
145 # Local TGZ:
147 set(proj TutorialStep1-LocalTGZ)
148 add_external_project(${proj}
149   TGZ "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz"
150   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix} -G ${CMAKE_GENERATOR} ${source_dir}/${proj}
151   INSTALL_COMMAND ""
154 set(proj TutorialStep1-LocalNoDirTGZ)
155 add_external_project(${proj}
156   TGZ "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
157   CMAKE_GENERATOR "${CMAKE_GENERATOR}"
158   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
159   INSTALL_COMMAND ""
163 # Download TAR:
165 # TODO: Add a remote .tar file
168 # Download TGZ:
170 # TODO: Add a remote .tgz file
173 # Download CVS:
175 if(can_use_cvs)
176   # CVS by date stamp:
177   #
178   set(proj TutorialStep1-20081201)
179   add_external_project(${proj}
180     CVS_REPOSITORY ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
181     CVS_MODULE "CMake/Tests/Tutorial/Step1"
182     CVS_TAG "-D2008-12-01 01:00:00 UTC"
183     CMAKE_GENERATOR "${CMAKE_GENERATOR}"
184     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
185     INSTALL_COMMAND ""
186   )
188   # CVS by tag:
189   #
190   set(proj kwsys-from-CMake-2-6-2)
191   add_external_project(${proj}
192     CVS_REPOSITORY ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
193     CVS_MODULE "CMake/Source/kwsys"
194     CVS_TAG -rCMake-2-6-2
195     CMAKE_GENERATOR "${CMAKE_GENERATOR}"
196     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
197     INSTALL_COMMAND ""
198   )
200   if(can_build_kwstyle)
201     # Live CVS / HEAD (no CVS_TAG):
202     #
203     set(proj KWStyle-CVSHEAD)
204     add_external_project(${proj}
205       CVS_REPOSITORY ":pserver:anoncvs@public.kitware.com:/cvsroot/KWStyle"
206       CVS_MODULE "KWStyle"
207       CMAKE_GENERATOR "${CMAKE_GENERATOR}"
208       CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
209       DEPENDS "EmptyNoOpProject"
210       DEPENDS "TutorialStep1-LocalTAR"
211       DEPENDS "TutorialStep1-LocalNoDirTAR"
212       DEPENDS "TutorialStep1-LocalTGZ"
213       DEPENDS "TutorialStep1-LocalNoDirTGZ"
214       DEPENDS "TutorialStep1-20081201"
215       DEPENDS "kwsys-from-CMake-2-6-2"
216     )
217   endif()
218 endif()
221 # Download SVN:
223 if(can_use_svn)
224   # SVN by date stamp:
225   #
226   set(proj gdcm-md5-20081204)
227   add_external_project(${proj}
228     SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
229     SVN_TAG "-r{2008-12-04 01:00:00 +0000}"
230     CMAKE_GENERATOR "${CMAKE_GENERATOR}"
231     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
232   )
234   # SVN by revision number:
235   #
236   set(proj gdcm-md5-r4824)
237   add_external_project(${proj}
238     SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
239     SVN_TAG "-r4824"
240     CMAKE_GENERATOR "${CMAKE_GENERATOR}"
241     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
242     INSTALL_COMMAND ""
243   )
245   # Live SVN / trunk (no SVN_TAG):
246   #
247   set(proj gdcm-md5-SVNtrunk)
248   add_external_project(${proj}
249     SVN_REPOSITORY "http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
250     CMAKE_GENERATOR "${CMAKE_GENERATOR}"
251     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
252     INSTALL_COMMAND ""
253   )
254 endif()
257 # Test the testable built/installed products:
259 enable_testing()
262 # Use these as input to the KWStyle tests:
264 set(kwstyleXmlFile "${source_dir}/KWStyle-CVSHEAD/Testing/Data/0001-KWStyleConfiguration.kws.xml")
265 set(header "${install_dir}/include/TutorialConfig.h")
268 # Do at least a smoke test of a built executable from each
269 # project's build directory...
271 # BuildTree tests:
273 if(can_build_tutorial_step5)
274   add_test(TutorialStep5-Local-BuildTreeTest
275     "${build_dir}/TutorialStep5-Local/Tutorial" 42)
276 endif()
278 add_test(TutorialStep1-LocalTAR-BuildTreeTest
279   "${build_dir}/TutorialStep1-LocalTAR/EP-Tutorial" 36)
281 add_test(TutorialStep1-LocalNoDirTAR-BuildTreeTest
282   "${build_dir}/TutorialStep1-LocalNoDirTAR/EP-Tutorial" 25)
284 add_test(TutorialStep1-LocalTGZ-BuildTreeTest
285   "${build_dir}/TutorialStep1-LocalTGZ/Tutorial" 16)
287 add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest
288   "${build_dir}/TutorialStep1-LocalNoDirTGZ/Tutorial" 9)
290 if(can_use_cvs)
291   add_test(TutorialStep1-20081201-BuildTreeTest
292     "${build_dir}/TutorialStep1-20081201/Tutorial" 4)
294   add_test(kwsys-from-CMake-2-6-2-BuildTreeTest
295     "${build_dir}/kwsys-from-CMake-2-6-2/kwsysTestProcess" 1)
297   if(can_build_kwstyle)
298     add_test(KWStyle-CVSHEAD-BuildTreeTest
299       "${build_dir}/KWStyle-CVSHEAD/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
300   endif()
301 endif()
303 if(can_use_svn)
304   add_test(gdcm-md5-20081204-BuildTreeTest
305     "${build_dir}/gdcm-md5-20081204/md5main" --version)
307   add_test(gdcm-md5-r4824-BuildTreeTest
308     "${build_dir}/gdcm-md5-r4824/md5main" --version)
310   add_test(gdcm-md5-SVNtrunk-BuildTreeTest
311     "${build_dir}/gdcm-md5-SVNtrunk/md5main" --version)
312 endif()
315 # InstallTree tests:
317 if(can_build_tutorial_step5)
318   add_test(TutorialStep5-InstallTreeTest
319     "${install_dir}/bin/Tutorial" 49)
320 endif()
322 if(can_use_cvs)
323   if(can_build_kwstyle)
324     add_test(KWStyle-InstallTreeTest
325       "${install_dir}/bin/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
326   endif()
327 endif()
329 if(can_use_svn)
330   add_test(gdcm-md5-InstallTreeTest
331     "${install_dir}/bin/md5main" --version)
332 endif()