aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-16 10:26:06 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-05-16 10:26:06 +0200
commit6621af007c13b12bb1d33d0edf75db600a42f742 (patch)
tree243863bfb7030a514c47cabd8b5f7fb2ac3b8d65 /cmake
parent829dd697c1797893753962df6af1a9ad1592263a (diff)
Improve OS detection
Every distribution name detected in ID_LIKE field could be used. Change-Id: I767b1bb20521248b30269955ce6a15912a62df33 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/common.cmake15
1 files changed, 11 insertions, 4 deletions
diff --git a/cmake/common.cmake b/cmake/common.cmake
index 2f3bcdc..e826bee 100644
--- a/cmake/common.cmake
+++ b/cmake/common.cmake
@@ -42,12 +42,13 @@ endif()
# Used to package .deb
set(OS_RELEASE_PATH "${BUILD_ENV_SYSROOT}/etc/os-release")
if(EXISTS ${OS_RELEASE_PATH})
- execute_process(COMMAND bash "-c" "grep -E '^ID(_LIKE)?=' /etc/os-release | tail -n 1 | sed -r 's:.*=\"(.*)\":\\1:' | awk '{print $1}'"
+ execute_process(COMMAND bash "-c" "grep -E '^ID(_LIKE)?=' /etc/os-release | tail -n 1"
OUTPUT_VARIABLE TMP_OSRELEASE
)
if (NOT TMP_OSRELEASE STREQUAL "")
- string(REGEX REPLACE ".*=\"?([0-9a-z\._-]*)\"?\n" "\\1" OSRELEASE ${TMP_OSRELEASE})
+ string(REGEX REPLACE ".*=\"?([0-9a-z\._ -]*)\"?\n" "\\1" OSDETECTED ${TMP_OSRELEASE})
+ string(REPLACE " " ";" OSRELEASE ${OSDETECTED})
else()
set(OSRELEASE "NOT COMPATIBLE !")
endif()
@@ -55,11 +56,17 @@ if(EXISTS ${OS_RELEASE_PATH})
else()
set(OSRELEASE "NOT COMPATIBLE ! Missing ${OS_RELEASE_PATH} file.")
endif()
-message(STATUS "Distribution used ${OSRELEASE}")
+message(STATUS "Distribution detected (separated by ';' choose one of them) ${OSRELEASE}")
file(GLOB project_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/cmake/cmake.d/[0-9][0-9]-*.cmake)
-file(GLOB distro_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-${OSRELEASE}*.cmake ${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-common*.cmake)
+foreach(OS IN LISTS OSRELEASE)
+ list(APPEND PATTERN "${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-${OS}*.cmake")
+endforeach()
+list(APPEND PATTERN "${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-common*.cmake")
+
+file(GLOB distro_cmakefiles ${PATTERN})
list(SORT distro_cmakefiles)
+
if(NOT distro_cmakefiles)
file(GLOB distro_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-default*.cmake)
endif()