cmake: introduce GCC_COMPILER_VERSION variable

Introduce GCC_COMPILER_VERSION to be used in Zephyr CMake when knowledge
of the current GCC Compiler version is needed and
CMAKE_C_COMPILER_VERSION has not been defined yet.

CMAKE_C_COMPILER_VERSION is not defined until project() is called.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2025-02-27 17:19:48 +01:00 committed by Fabio Baltieri
commit 41ac85a2c5

View file

@ -39,11 +39,11 @@ endif()
# Add check for GCC version >= 13.1 # Add check for GCC version >= 13.1
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpfullversion COMMAND ${CMAKE_C_COMPILER} -dumpfullversion
OUTPUT_VARIABLE temp_compiler_version OUTPUT_VARIABLE GCC_COMPILER_VERSION
) )
if("${temp_compiler_version}" VERSION_LESS 4.3.0 OR if("${GCC_COMPILER_VERSION}" VERSION_LESS 4.3.0 OR
"${temp_compiler_version}" VERSION_GREATER_EQUAL 13.1.0) "${GCC_COMPILER_VERSION}" VERSION_GREATER_EQUAL 13.1.0)
set(fix_header_file include/limits.h) set(fix_header_file include/limits.h)
else() else()
set(fix_header_file include-fixed/limits.h) set(fix_header_file include-fixed/limits.h)