Detect linux distribution and version

This commit is contained in:
Axel Kohlmeyer 2021-04-14 20:00:38 -04:00
parent 8aed7e55b3
commit d5661e06ae
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 10 additions and 0 deletions

View File

@ -104,3 +104,13 @@ function(FetchPotentials pkgfolder potfolder)
endforeach()
endif()
endfunction(FetchPotentials)
# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux
if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release))
file(STRINGS /etc/os-release distro REGEX "^NAME=")
string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}")
file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=")
string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}")
set(CMAKE_LINUX_DISTRO ${distro})
set(CMAKE_DISTRO_VERSION ${disversion})
endif()