summaryrefslogtreecommitdiffstats
path: root/cmake/common.cmake
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-28 18:54:41 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 18:22:47 +0200
commitf4f3096182589b7031905511d44b86cc7ff0bfa4 (patch)
tree76b6a5b55dc9bc925f1a9bacce983a4942f9cd3e /cmake/common.cmake
parent215e4b27ddf0908539d34352fbeed62f19521206 (diff)
Dirty fix to handle distro specific packages deps
Could include first distro specific file to be able to modify variable from config.cmake and then process classic submodule cmake files. Change-Id: Id5dad2504d44c86cb165ad56f5314e9c0c545f0b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake/common.cmake')
-rw-r--r--cmake/common.cmake38
1 files changed, 27 insertions, 11 deletions
diff --git a/cmake/common.cmake b/cmake/common.cmake
index d0ec12e..ad5567a 100644
--- a/cmake/common.cmake
+++ b/cmake/common.cmake
@@ -24,8 +24,35 @@
# Customise your preferences in "./conf.d/cmake/config.cmake"
#--------------------------------------------------------------------------
+# Get the os type
+# 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)?=' ${OS_RELEASE_PATH} | tail -n 1"
+ OUTPUT_VARIABLE TMP_OSRELEASE
+ )
+
+ if (NOT TMP_OSRELEASE STREQUAL "")
+ string(REGEX REPLACE ".*=\"?([0-9a-z\._-]*)\"?\n" "\\1" OSRELEASE ${TMP_OSRELEASE})
+ else()
+ set(OSRELEASE "NOT COMPATIBLE !")
+ endif()
+
+else()
+ set(OSRELEASE "NOT COMPATIBLE ! Missing ${OS_RELEASE_PATH} file.")
+endif()
+message(STATUS "Distribution used ${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)
+list(SORT distro_cmakefiles)
+if(NOT distro_cmakefiles)
+ file(GLOB distro_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-default*.cmake)
+endif()
+
+list(APPEND project_cmakefiles "${distro_cmakefiles}")
list(SORT project_cmakefiles)
+
file(GLOB home_cmakefiles $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-common*.cmake $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake)
list(SORT home_cmakefiles)
file(GLOB system_cmakefiles /etc/app-templates/cmake.d/[0-9][0-9]-common*.cmake /etc/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake)
@@ -36,17 +63,6 @@ foreach(file ${system_cmakefiles} ${home_cmakefiles} ${project_cmakefiles})
include(${file})
endforeach()
-file(GLOB project_cmakefiles ${ENTRY_POINT}/cmake/[0-9][0-9]-${OSRELEASE}*.cmake )
-list(SORT project_cmakefiles)
-if(NOT project_cmakefiles)
- file(GLOB project_cmakefiles ${ENTRY_POINT}/cmake/[0-9][0-9]-default*.cmake)
-endif()
-
-foreach(file ${project_cmakefiles})
- message(STATUS "Include: ${file}")
- include(${file})
-endforeach()
-
if(DEFINED PROJECT_SRC_DIR_PATTERN)
project_subdirs_add(${PROJECT_SRC_DIR_PATTERN})
else()