mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
cmake: Fix -Wno- handling in add_cxx_flag_if_supported (#1656)
The `-Wno-...` compiler flags only result in a diagnostic if another diagnostic is emitted. When passing such flags to `add_cxx_flag_if_supported` (and `check_cxx_compiler_flag`), the test would always succeed. For such cases, test the `-W...` flag instead of the `-Wno-...` flag. Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
9afb918bf5
commit
8e74722a0a
@@ -82,9 +82,15 @@ endif()
|
|||||||
|
|
||||||
macro(add_cxx_flag_if_supported flag)
|
macro(add_cxx_flag_if_supported flag)
|
||||||
string(REGEX REPLACE "[-=+]" "" FLAG_NO_SIGNS ${flag})
|
string(REGEX REPLACE "[-=+]" "" FLAG_NO_SIGNS ${flag})
|
||||||
check_cxx_compiler_flag(${flag} COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
|
set(FLAG_TO_TEST ${flag})
|
||||||
|
if((${flag} MATCHES "^-Wno-") AND NOT (${flag} MATCHES "^-Wno-error="))
|
||||||
|
# -Wno-... only causes a diagnostic if another diagnostic is emitted.
|
||||||
|
# Change such flags into a -W... flag to test if the warning is known.
|
||||||
|
string(REGEX REPLACE "^-Wno-" "-W" FLAG_TO_TEST ${flag})
|
||||||
|
endif()
|
||||||
|
check_cxx_compiler_flag(${FLAG_TO_TEST} COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
|
||||||
if(COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
|
if(COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||||
endif()
|
endif()
|
||||||
endmacro(add_cxx_flag_if_supported)
|
endmacro(add_cxx_flag_if_supported)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user