ENH: Use a TryCheckout technique to decide whether or not to attempt building the projects that depend on a cvs or svn download method.

This commit is contained in:
David Cole 2008-12-04 15:30:37 -05:00
parent 930827d48c
commit 67ebcb9597
2 changed files with 84 additions and 6 deletions

View File

@ -9,6 +9,30 @@ get_external_project_directories(base_dir build_dir downloads_dir install_dir
set(prefix "${install_dir}")
# 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")
try_cvs_checkout(
":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake"
"CMake/Tests/Tutorial/Step1"
"${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/TutorialStep1"
can_use_cvs
)
try_svn_checkout(
"http://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk/Utilities/gdcmmd5"
"${CMAKE_CURRENT_BINARY_DIR}/TryCheckout/gdcmmd5"
can_use_svn
)
message(STATUS "can_use_cvs='${can_use_cvs}'")
message(STATUS "can_use_svn='${can_use_svn}'")
# Local DIR:
#
set(proj TutorialStep5-Local)
@ -64,7 +88,7 @@ add_external_project(${proj}
# Download CVS:
#
if(CVS_EXECUTABLE)
if(can_use_cvs)
# CVS by date stamp:
#
set(proj KWStyle-20081201)
@ -100,7 +124,7 @@ endif()
# Download SVN:
#
if(Subversion_SVN_EXECUTABLE)
if(can_use_svn)
# SVN by date stamp:
#
set(proj gdcm-md5-20081204)
@ -162,7 +186,7 @@ add_test(TutorialStep1-LocalTGZ-BuildTreeTest
add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest
"${build_dir}/TutorialStep1-LocalNoDirTGZ/Tutorial" 9)
if(CVS_EXECUTABLE)
if(can_use_cvs)
add_test(KWStyle-20081201-BuildTreeTest
"${build_dir}/KWStyle-20081201/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
@ -173,7 +197,7 @@ if(CVS_EXECUTABLE)
"${build_dir}/TutorialStep1-LocalNoDirTGZ/Tutorial" 4)
endif()
if(Subversion_SVN_EXECUTABLE)
if(can_use_svn)
add_test(gdcm-md5-20081204-BuildTreeTest
"${build_dir}/gdcm-md5-20081204/md5main" --version)
@ -190,12 +214,12 @@ endif()
add_test(TutorialStep5-InstallTreeTest
"${install_dir}/bin/Tutorial" 49)
if(CVS_EXECUTABLE)
if(can_use_cvs)
add_test(KWStyle-InstallTreeTest
"${install_dir}/bin/KWStyle" -xml "${kwstyleXmlFile}" "${header}")
endif()
if(Subversion_SVN_EXECUTABLE)
if(can_use_svn)
add_test(gdcm-md5-InstallTreeTest
"${install_dir}/bin/md5main" --version)
endif()

View File

@ -0,0 +1,54 @@
find_package(CVS)
find_package(Subversion)
function(try_cvs_checkout repository module dir result_var)
# Assume cvs checkouts will not work:
set(${result_var} 0 PARENT_SCOPE)
if(CVS_EXECUTABLE)
message(STATUS "try_cvs_checkout")
# Ensure directory exists so we can call cvs in it:
file(MAKE_DIRECTORY "${dir}")
# Try to do the cvs checkout command:
execute_process(COMMAND ${CVS_EXECUTABLE} -d ${repository} co ${module}
WORKING_DIRECTORY ${dir}
TIMEOUT 30
RESULT_VARIABLE rv)
# If it worked, cvs checkouts will work:
if(rv EQUAL 0)
set(${result_var} 1 PARENT_SCOPE)
endif()
message(STATUS "try_cvs_checkout -- done")
endif()
endfunction(try_cvs_checkout)
function(try_svn_checkout repository dir result_var)
# Assume svn checkouts will not work:
set(${result_var} 0 PARENT_SCOPE)
if(Subversion_SVN_EXECUTABLE)
message(STATUS "try_svn_checkout")
# Ensure directory exists so we can call svn in it:
file(MAKE_DIRECTORY "${dir}")
# Try to do the svn checkout command:
execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} co ${repository} ${dir}
WORKING_DIRECTORY ${dir}
TIMEOUT 30
RESULT_VARIABLE rv)
# If it worked, svn checkouts will work:
if(rv EQUAL 0)
set(${result_var} 1 PARENT_SCOPE)
endif()
message(STATUS "try_svn_checkout -- done")
endif()
endfunction(try_svn_checkout)