summaryrefslogtreecommitdiffstats
path: root/cmake/cmake.d/01-variables.cmake
diff options
context:
space:
mode:
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>2017-07-27 17:33:11 +0200
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>2017-07-27 17:33:11 +0200
commita78f50b38d8753667da416ea64d5c6b5f29c0a3e (patch)
tree947626c03a4b3e79a8af222a5d2c94af5b131a8b /cmake/cmake.d/01-variables.cmake
parent97348c43db647c0025919350383ce7d561761cb4 (diff)
parentdee58363ddb98f8e63239035f1a8f1ab151c5e96 (diff)
Diffstat (limited to 'cmake/cmake.d/01-variables.cmake')
-rw-r--r--cmake/cmake.d/01-variables.cmake15
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})