diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-07-25 12:40:02 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-15 18:22:47 +0200 |
commit | 4231d6c43ac1fe120138700b130fd14411048fc3 (patch) | |
tree | c3b66817c5222bec7d8cb3cad9507cf95e410031 /cmake/cmake.d/01-variables.cmake | |
parent | 5ec4a4e9bfae4fe550b5e3f23dadca03c1ea2474 (diff) |
2 Kernel checks available (warning or mandatory)
Use 2 differents checks, one specify a mandatory kernel version
and the other will output a warning and position a preprocessing
variable that can be used in the code to exclude portions of code
that use kernel features not available under a certain version.
Change-Id: Ifc6848df1a1a448094f5312ea23e6d4837e8ef14
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake/cmake.d/01-variables.cmake')
-rw-r--r-- | cmake/cmake.d/01-variables.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/cmake.d/01-variables.cmake b/cmake/cmake.d/01-variables.cmake index 1bba5ce..3891f53 100644 --- a/cmake/cmake.d/01-variables.cmake +++ b/cmake/cmake.d/01-variables.cmake @@ -71,6 +71,21 @@ else() set(OSRELEASE "NOT DEBIAN OS") endif() +if(DEFINED ENV{SDKTARGETSYSROOT}) + file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") +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") +else() + file(STRINGS /usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") +endif() + +string(REGEX MATCH "[0-9]+" LINUX_VERSION_CODE ${LINUX_VERSION_CODE_LINE}) +math(EXPR a "${LINUX_VERSION_CODE} >> 16") +math(EXPR b "(${LINUX_VERSION_CODE} >> 8) & 255") +math(EXPR c "(${LINUX_VERSION_CODE} & 255)") + +set(KERNEL_VERSION "${a}.${b}.${c}") + # Include project configuration # ------------------------------ project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES}) |