TZIVI-254: IVI needs a newer version of cmake
[profile/ivi/cmake.git] / Tests / ExternalProject / TryCheckout.cmake
1 find_package(CVS)
2 find_package(Subversion)
3
4
5 function(try_cvs_checkout repository module dir result_var)
6   # Assume cvs checkouts will not work:
7   set(${result_var} 0 PARENT_SCOPE)
8
9   if(CVS_EXECUTABLE)
10     message(STATUS "try_cvs_checkout")
11
12     # Ensure directory exists so we can call cvs in it:
13     file(MAKE_DIRECTORY "${dir}")
14
15     # Try to do the cvs checkout command:
16     execute_process(COMMAND ${CVS_EXECUTABLE} -d ${repository} co ${module}
17       WORKING_DIRECTORY ${dir}
18       TIMEOUT 30
19       RESULT_VARIABLE rv)
20
21     # If it worked, cvs checkouts will work:
22     if(rv EQUAL 0)
23       set(${result_var} 1 PARENT_SCOPE)
24     endif()
25
26     message(STATUS "try_cvs_checkout -- done")
27   endif()
28 endfunction(try_cvs_checkout)
29
30
31 function(try_svn_checkout repository dir result_var)
32   # Assume svn checkouts will not work:
33   set(${result_var} 0 PARENT_SCOPE)
34
35   if(Subversion_SVN_EXECUTABLE)
36     message(STATUS "try_svn_checkout")
37
38     # Ensure directory exists so we can call svn in it:
39     file(MAKE_DIRECTORY "${dir}")
40
41     # Try to do the svn checkout command:
42     execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} co ${repository} ${dir}
43       WORKING_DIRECTORY ${dir}
44       TIMEOUT 30
45       RESULT_VARIABLE rv)
46
47     # If it worked, svn checkouts will work:
48     if(rv EQUAL 0)
49       set(${result_var} 1 PARENT_SCOPE)
50     endif()
51
52     message(STATUS "try_svn_checkout -- done")
53   endif()
54 endfunction(try_svn_checkout)