diff options
Diffstat (limited to 'functions.cmake')
-rw-r--r-- | functions.cmake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/functions.cmake b/functions.cmake index 3212ea04a65..cc8f1c5b038 100644 --- a/functions.cmake +++ b/functions.cmake @@ -590,3 +590,26 @@ function(add_extra_projects) endif() endfunction() +function(vespa_detect_build_platform) + if(EXISTS /etc/os-release) + file(STRINGS /etc/os-release OS_DISTRO REGEX "^ID=") + string(REGEX REPLACE "ID=\"?([^\"]+)\"?" "\\1" OS_DISTRO ${OS_DISTRO}) + file(STRINGS /etc/os-release OS_DISTRO_VERSION REGEX "^VERSION_ID=") + string(REGEX REPLACE "VERSION_ID=\"?([^\"]+)\"?" "\\1" OS_DISTRO_VERSION ${OS_DISTRO_VERSION}) + elseif(EXISTS /etc/redhat-release) + set(OS_DISTRO "rhel") + file(STRINGS "/etc/redhat-release" OS_DISTRO_VERSION) + string(REGEX REPLACE ".* release ([0-9.]+) .*" "\\1" OS_DISTRO_VERSION ${OS_DISTRO_VERSION}) + elseif(APPLE) + set(OS_DISTRO "darwin") + set(OS_DISTRO_VERSION ${CMAKE_SYSTEM_VERSION}) + endif() + if(OS_DISTRO) + set(VESPA_OS_DISTRO ${OS_DISTRO} PARENT_SCOPE) + set(VESPA_OS_DISTRO_VERSION ${OS_DISTRO_VERSION} PARENT_SCOPE) + string(CONCAT OS_DISTRO_COMBINED ${OS_DISTRO} " " ${OS_DISTRO_VERSION}) + set(VESPA_OS_DISTRO_COMBINED ${OS_DISTRO_COMBINED} PARENT_SCOPE) + else() + message(FATAL_ERROR "-- Could not determine vespa build platform") + endif() +endfunction() |