cmake: add -Wformat when checking -Wformat-extra-args

The need for -Wformat when using -Wformat-extra-args was observed for
the msys2 mingw64 gcc toolchain.
This commit is contained in:
Anonymous Maarten 2023-01-07 22:25:09 +01:00 committed by Anonymous Maarten
parent e85e11b211
commit 1d60030e84

View file

@ -208,8 +208,6 @@ add_sdl_test_executable(gamepadmap NEEDS_RESOURCES TESTUTILS gamepadmap.c)
add_sdl_test_executable(testvulkan testvulkan.c)
add_sdl_test_executable(testoffscreen testoffscreen.c)
cmake_push_check_state()
check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW)
if(HAVE_WFORMAT_OVERFLOW)
target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_OVERFLOW)
@ -220,13 +218,17 @@ if(HAVE_WFORMAT)
target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT)
endif()
cmake_push_check_state()
if(HAVE_WFORMAT)
# Some compilers ignore -Wformat-extra-args without -Wformat
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wformat")
endif()
check_c_compiler_flag(-Wformat-extra-args HAVE_WFORMAT_EXTRA_ARGS)
cmake_pop_check_state()
if(HAVE_WFORMAT_EXTRA_ARGS)
target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_EXTRA_ARGS)
endif()
cmake_pop_check_state()
if(SDL_DUMMYAUDIO)
list(APPEND SDL_TESTS_NONINTERACTIVE
testaudioinfo