diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-26 12:25:13 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-26 12:25:13 +0200 |
commit | fb1eae26755fe25c1efb56d30261dfebf6e87fcc (patch) | |
tree | 6eaef95e7f6b274a911c50657d319cd730dba881 /cmake | |
parent | c5fa2bdc0136378cdec8674cca591fd90defd669 (diff) |
Check Kernel version against SDK env or Host env.
This use Kernel header version.h to determine which
is the current kernel version use to develop the project
Change-Id: I0a654a5a0fc89543fa3d855c7adc6d319dd0b53c
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/common.cmake | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/cmake/common.cmake b/cmake/common.cmake index f140802..ec0ffcf 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -30,7 +30,8 @@ include(${PROJECT_APP_TEMPLATES_DIR}/cmake/extra_targets.cmake) # Check GCC minimal version if (gcc_minimal_version) - message (STATUS "${Blue}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}") + message (STATUS "${Cyan}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) \ + (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version}) message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER") endif() @@ -38,10 +39,23 @@ endif(gcc_minimal_version) # Check Kernel minimal version if (kernel_minimal_version) - message (STATUS "${Blue}-- Check kernel_minimal_version (found kernel version ${CMAKE_SYSTEM_VERSION})${ColourReset}") - if (CMAKE_SYSTEM_VERSION VERSION_LESS ${kernel_minimal_version}) - message(FATAL_ERROR "${Red}**** FATAL: Require at least ${kernel_minimal_version} please use a recent kernel.") -endif() + if(DEFINED ENV{SDKTARGETSYSROOT}) + file(STRINGS $ENV{SDKTARGETSYSROOT}/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}") + message (STATUS "${Cyan}-- Check kernel_minimal_version (found kernel version ${KERNEL_VERSION})${ColourReset}") + + if (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version}) + message(FATAL_ERROR "${Red}**** FATAL: Require at least ${kernel_minimal_version} please use a recent kernel or source your SDK environment then clean and reconfigure your CMake project.") + endif (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version}) endif(kernel_minimal_version) INCLUDE(FindPkgConfig) |