diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index e28f416b9d..cbb640ca15 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -747,8 +747,17 @@ function(zephyr_check_compiler_flag lang option check) return() endif() - # Test the flag - check_compiler_flag(${lang} "${option}" inner_check) + # Flags that start with -Wno- can not be tested by + # check_compiler_flag, they will always pass, but -W can be + # tested, so to test -Wno- flags we test -W + # instead. + if("${option}" MATCHES "-Wno-(.*)") + set(possibly_translated_option -W${CMAKE_MATCH_1}) + else() + set(possibly_translated_option ${option}) + endif() + + check_compiler_flag(${lang} "${possibly_translated_option}" inner_check) set(${check} ${inner_check} PARENT_SCOPE)