From 201f70244aee772d20c523278c54175ae1211082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Mon, 9 Dec 2019 13:30:56 +0100 Subject: [PATCH] cmake: toolchain: Don't add -Werror=implicit-int to CXX builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do compiler flag compatibility tests to be able to support many different toolchains and flags in a scalable way. But the test is not perfect and in these situations we we will need to hardcode whether a flag is compatible or not. To support this we have zephyr_compiler_check first check if the flag is covered by a hardcoded test before testing it. Currently the only hardcoded compatibilty is that -Werror=implicit-int is not supported for CXX. This fixes #21229 Signed-off-by: Sebastian Bøe --- cmake/extensions.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index f553313a5be1..f52a0da56537 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -746,6 +746,14 @@ endfunction() # caching comes in addition to the caching that CMake does in the # build folder's CMakeCache.txt) function(zephyr_check_compiler_flag lang option check) + # Check if the option is covered by any hardcoded check before doing + # an automated test. + zephyr_check_compiler_flag_hardcoded(${lang} "${option}" check exists) + if(exists) + set(check ${check} PARENT_SCOPE) + return() + endif() + # Locate the cache directory set_ifndef( ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_DIR @@ -842,6 +850,19 @@ function(zephyr_check_compiler_flag lang option check) endif() endfunction() +function(zephyr_check_compiler_flag_hardcoded lang option check exists) + # -Werror=implicit-int is not supported for CXX and we are not able + # to automatically test for it because it produces a warning + # instead of an error during the test. + if((${lang} STREQUAL CXX) AND ("${option}" STREQUAL -Werror=implicit-int)) + set(check 0 PARENT_SCOPE) + set(exists 1 PARENT_SCOPE) + else() + # There does not exist a hardcoded check for this option. + set(exists 0 PARENT_SCOPE) + endif() +endfunction(zephyr_check_compiler_flag_hardcoded) + # zephyr_linker_sources( ) # # is one or more .ld formatted files whose contents will be