Merge remote-tracking branch 'origin/master' into dab 4.0.0 4.0.1 4.0.2 4.0.3 dab/4.0.0 dab/4.0.1 dab/4.0.2 dab/4.0.3 dab_4.0.0 dab_4.0.1 dab_4.0.2 dab_4.0.3
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>
Thu, 27 Jul 2017 15:33:11 +0000 (17:33 +0200)
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>
Thu, 27 Jul 2017 15:33:11 +0000 (17:33 +0200)
cmake/cmake.d/01-variables.cmake
cmake/cmake.d/04-build_options.cmake
cmake/config.cmake.sample

index 1bba5ce..3891f53 100644 (file)
@@ -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})
index d1b25f4..18a1b17 100644 (file)
@@ -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)
 
@@ -75,18 +72,19 @@ add_compile_options(-fPIC)
 # TODO: make more visible readable compile (macro ? split ?)
 # Compilation option depending on CMAKE_BUILD_TYPE
 ##################################################
-add_compile_options($<$<OR:$<CONFIG:DEBUG>,$<CONFIG:PROFILING>,$<CONFIG:CCOV>>:-g>)
-
-add_compile_options($<$<CONFIG:DEBUG>:-ggdb>)
-add_compile_options($<$<CONFIG:CCOV>:--coverage>)
-
-add_compile_options($<$<CONFIG:DEBUG>:-Og>)
+add_compile_options($<$<CONFIG:PROFILING>:-g>)
 add_compile_options($<$<CONFIG:PROFILING>:-O0>)
 add_compile_options($<$<CONFIG:PROFILING>:-pg>)
-add_compile_options($<$<OR:$<CONFIG:CCOV>,$<CONFIG:PROFILING>>:-O2>)
+add_compile_options($<$<CONFIG:PROFILING>:-Wp,-U_FORTIFY_SOURCE>)
 
-add_compile_options($<$<OR:$<CONFIG:DEBUG>,$<CONFIG:PROFILING>>:-Wp,-U_FORTIFY_SOURCE>)
+add_compile_options($<$<CONFIG:DEBUG>:-g>)
+add_compile_options($<$<CONFIG:DEBUG>:-O0>)
+add_compile_options($<$<CONFIG:DEBUG>:-ggdb>)
+add_compile_options($<$<CONFIG:DEBUG>:-Wp,-U_FORTIFY_SOURCE>)
 
+add_compile_options($<$<CONFIG:CCOV>:-g>)
+add_compile_options($<$<CONFIG:CCOV>:-O2>)
+add_compile_options($<$<CONFIG:CCOV>:--coverage>)
 
 # Env variable overload default
 if(DEFINED ENV{INSTALL_PREFIX})
index fb878a2..23f1e80 100644 (file)
@@ -47,10 +47,18 @@ set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates")
 # ----------------------------------
 set(CMAKE_BUILD_TYPE "DEBUG")
 
-# Kernel selection if needed. Impose a minimal version.
-# NOTE FOR NOW IT CHECKS KERNEL Yocto SDK Kernel version
-# else only HOST VERSION
+# Kernel selection if needed. You can choose between a
+# mandatory version to impose a minimal version.
+# Or check Kernel minimal version and just print a Warning
+# about missing features and define a preprocessor variable
+# to be used as preprocessor condition in code to disable
+# incompatibles features. Preprocessor define is named
+# KERNEL_MINIMAL_VERSION_OK.
+#
+# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and
+# Yocto SDK Kernel version.
 # -----------------------------------------------
+#set (kernel_mandatory_version 4.8)
 #set (kernel_minimal_version 4.8)
 
 # Compiler selection if needed. Impose a minimal version.