summaryrefslogtreecommitdiffstats
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-10-15 18:22:48 +0200
commit4170a6ca99923c5d57690481f003db81083ab79c (patch)
treecc61f86d4e59d5c708bf2bfc655db419f2f8c5c9
parent9537f8de82c9916420b1eee0957c041fe4709f26 (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>
-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()