Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroGetLinuxDistribution.cmake
Go to the documentation of this file.
2 
3 execute_process(COMMAND lsb_release -a OUTPUT_VARIABLE _out ERROR_VARIABLE _err RESULT_VARIABLE _result)
4 
5 string(COMPARE EQUAL "${_out}" "" _ok)
6 
7 if(_ok)
8  string(REGEX REPLACE "\n" ";" _out ${_err})
9 else()
10  string(REGEX REPLACE "\n" ";" _out ${_out})
11 endif()
12 
13 foreach(_i ${_out})
14 
15  if("${_i}" MATCHES "^[Rr][Ee][Ll][Ee][Aa][Ss][Ee].*")
16  string(REGEX REPLACE ":" ";" _i ${_i})
17  list(GET _i -1 _i)
18  string(STRIP ${_i} _release)
19  endif()
20 
21  if("${_i}" MATCHES "^[Dd][Ii][Ss][Tt][Rr][Ii][Bb][Uu][Tt][Oo][Rr].*")
22  string(REGEX REPLACE ":" ";" _i ${_i})
23  list(GET _i -1 _i)
24  string(STRIP ${_i} _distrib)
25  endif()
26 
27 endforeach(_i)
28 
29 string(COMPARE EQUAL "${_distrib}" "" _ok1)
30 string(COMPARE EQUAL "${_release}" "" _ok2)
31 
32 if(${_ok1} OR ${_ok2})
33  message(SEND_ERROR "could not determine linux release!")
34 endif()
35 
36 set(LINUX_DISTRIBUTION ${_distrib})
37 set(LINUX_RELEASE ${_release})
38 
39 endmacro()
GetLinuxDistribution()