SetSubMinorRevision.cmake 1.26 KB
Newer Older
Naumann, Andreas's avatar
Naumann, Andreas committed
1
2
3
#this files sets the cmake variable AMDIS_SUB_MINOR to the subversion global revision
#if the global revision could not be determined, the variable remains empty
#TODO: git compatibility
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


macro(Subversion_CHECK_WC dir prefix)
  set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
  set(ENV{LC_ALL} C)
  execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
      OUTPUT_VARIABLE ${prefix}_WC_INFO
      ERROR_VARIABLE Subversion_svn_info_error
      RESULT_VARIABLE Subversion_svn_info_result
      OUTPUT_STRIP_TRAILING_WHITESPACE)

 if(${Subversion_svn_info_result} EQUAL 0)
   set(${prefix} TRUE)
   #message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
 else()
   set(${prefix} FALSE)
 endif()
  # restore the previous LC_ALL
    set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})
  endmacro()
Naumann, Andreas's avatar
Naumann, Andreas committed
24
25
find_package(Subversion)
if(Subversion_FOUND)
26
27
28
29
30
31
32
#CMake Version 3.5.2: fatal error in Subversion_WC_INFO if CMAKE_CURRENT_SOURCE_DIR is not a working directory
   Subversion_CHECK_WC(${CMAKE_CURRENT_SOURCE_DIR} svn_check)
   if(svn_check)
     Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} svn_info)
     #message("svn-rev: ${svn_info_WC_REVISION}")
     set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}")
   endif()
Naumann, Andreas's avatar
Naumann, Andreas committed
33
 endif()