summaryrefslogtreecommitdiffstats
path: root/ctl-lib/CMakeLists.txt
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-01-03 15:03:39 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-01-03 16:48:48 +0100
commit680af25d7b89e734b77ddad0f4e2d2a4d1bc8826 (patch)
tree53a3377e1c681678164e8e276c41ddf7b019d638 /ctl-lib/CMakeLists.txt
parent565e5a7fac5db9a35fd0b2cb8e12f1bdf4772821 (diff)
Adding packaging files
Add necessary files to build native packages for AGL supported linux distributions Bug-AGL: SPEC-2097 Change-Id: Ife6d1ec8a05f40e0bd70e741859133003716b37a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/CMakeLists.txt')
-rw-r--r--ctl-lib/CMakeLists.txt45
1 files changed, 41 insertions, 4 deletions
diff --git a/ctl-lib/CMakeLists.txt b/ctl-lib/CMakeLists.txt
index e2fd683..4ca83cc 100644
--- a/ctl-lib/CMakeLists.txt
+++ b/ctl-lib/CMakeLists.txt
@@ -24,6 +24,38 @@ set(PROJECT_AUTHOR_MAIL "fulup@iot.bzh")
set(PROJECT_LICENSE "APL2.0")
set(PROJECT_LANGUAGES "C")
+
+if(DEFINED ENV{SDKTARGETSYSROOT})
+file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE")
+set(BUILD_ENV_SYSROOT $ENV{SDKTARGETSYSROOT})
+elseif(DEFINED ENV{PKG_CONFIG_SYSROOT_DIR})
+file(STRINGS $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE")
+set(BUILD_ENV_SYSROOT $ENV{PKG_CONFIG_SYSROOT_DIR})
+else()
+file(STRINGS /usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE")
+set(BUILD_ENV_SYSROOT "")
+endif()
+
+# 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" OSDETECTED ${TMP_OSRELEASE})
+ else()
+ set(OSDETECTED "NOT COMPATIBLE !")
+ endif()
+elseif("${BUILD_ENV_SYSROOT}" STREQUAL "$ENV{PKG_CONFIG_SYSROOT_DIR}")
+ set(OSDETECTED "yocto-build")
+else()
+ set(OSDETECTED "NOT COMPATIBLE ! Missing ${OS_RELEASE_PATH} file.")
+endif()
+message("Distribution detected ${OSDETECTED}")
+
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr")
endif()
@@ -31,14 +63,19 @@ add_definitions(-DAFB_BINDING_VERSION=3)
add_definitions(-DLUA_GLOB_PATTERN="/var/?.lua\\\;")
add_definitions(-DSUSE_LUA_INCDIR)
-
INCLUDE(FindPkgConfig)
+
set (PKG_REQUIRED_LIST
- afb-daemon
- afb-helpers
- lua
+ afb-daemon
+ afb-helpers
)
+if(${OSDETECTED} STREQUAL "debian")
+ list(APPEND PKG_REQUIRED_LIST lua53)
+else()
+ list(APPEND PKG_REQUIRED_LIST lua)
+endif()
+
# Loop on required package and add options
foreach (PKG_CONFIG ${PKG_REQUIRED_LIST})
string(REGEX REPLACE "[<>]?=.*$" "" XPREFIX ${PKG_CONFIG})