aboutsummaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2020-01-07 11:51:03 +0100
committerTor Egge <Tor.Egge@broadpark.no>2020-01-07 11:51:03 +0100
commit40477696dbe02c9ab142719cb8c5fa5fa2e1a858 (patch)
treed038458882d8b069c31c46eee8c396758ddd9623 /functions.cmake
parent25da72ef231afeb7e1689eabdcf9500a5cb5d14d (diff)
Setup default build settings based on detected vespa build platform using cmake.
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake23
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()