X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=cmake%2Fcmake.d%2F04-build_options.cmake;h=18a1b176aac1dabd6265ab0f6bdd88052389814f;hb=e554c093bc7792d9d3a335372e972d9bfab42499;hp=899505f61187460df2f4fec3fc3b95d4d00f8dd7;hpb=5989f68a47567569a957b81ba64cbd8fef0bccc5;p=staging%2Fxdg-launcher.git diff --git a/cmake/cmake.d/04-build_options.cmake b/cmake/cmake.d/04-build_options.cmake index 899505f..18a1b17 100644 --- a/cmake/cmake.d/04-build_options.cmake +++ b/cmake/cmake.d/04-build_options.cmake @@ -33,26 +33,23 @@ if (gcc_minimal_version) endif() endif(gcc_minimal_version) -# Check Kernel minimal version +# Check Kernel mandatory version, will fail the configuration if required version not matched. +if (kernel_mandatory_version) + message (STATUS "${Cyan}-- Check kernel_mandatory_version (found kernel version ${KERNEL_VERSION})${ColourReset}") + if (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version}) + message(FATAL_ERROR "${Red}**** FATAL: Require at least ${kernel_mandatory_version} please use a recent kernel or source your SDK environment then clean and reconfigure your CMake project.") + endif (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version}) +endif(kernel_mandatory_version) + +# Check Kernel minimal version just print a Warning about missing features +# and set a definition to be used as preprocessor condition in code to disable +# incompatibles features. if (kernel_minimal_version) - 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}") 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.") + message(WARNING "${Yellow}**** Warning: Some feature(s) require at least ${kernel_minimal_version}. Please use a recent kernel or source your SDK environment then clean and reconfigure your CMake project.${ColourReset}") + else (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version}) + add_definitions(-DKERNEL_MINIMAL_VERSION_OK) endif (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version}) endif(kernel_minimal_version)