summaryrefslogtreecommitdiffstats
path: root/Tests/ExternalProject/TryCheckout.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2008-12-04 20:30:37 (GMT)
committerDavid Cole <david.cole@kitware.com>2008-12-04 20:30:37 (GMT)
commit67ebcb9597a06fb151bdc460b9e461b1508b278b (patch)
tree6e6f9737d89cfd48640396c13e17c386be60e980 /Tests/ExternalProject/TryCheckout.cmake
parent930827d48c39b34e8950cae1a417e53bdbdade0e (diff)
downloadCMake-67ebcb9597a06fb151bdc460b9e461b1508b278b.zip
CMake-67ebcb9597a06fb151bdc460b9e461b1508b278b.tar.gz
CMake-67ebcb9597a06fb151bdc460b9e461b1508b278b.tar.bz2
ENH: Use a TryCheckout technique to decide whether or not to attempt building the projects that depend on a cvs or svn download method.
Diffstat (limited to 'Tests/ExternalProject/TryCheckout.cmake')
-rw-r--r--Tests/ExternalProject/TryCheckout.cmake54
1 files changed, 54 insertions, 0 deletions
diff --git a/Tests/ExternalProject/TryCheckout.cmake b/Tests/ExternalProject/TryCheckout.cmake
new file mode 100644
index 0000000..de069eb
--- /dev/null
+++ b/Tests/ExternalProject/TryCheckout.cmake
@@ -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)