From a6139b349108f40f1b570e7ed49102d46e284a9d Mon Sep 17 00:00:00 2001 From: Hajin Jang Date: Tue, 26 Sep 2023 02:15:10 +0900 Subject: [PATCH] Detect -Wno-pedantic-ms-format support in mingw Use check_c_compiler_flag() feature of CMake to figure out whether this mingw toolchain has support for -Wno-pedantic-ms-format or not. This flag will be added only if the toolchain supports it. Currently, MinGW-w64 GCC has it, and llvm-mingw does not have it. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b53e8c8..974af49c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,9 +239,9 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif() endif() if(MINGW) - # Add `-Wno-pedantic-ms-format` only if the toolchain is GCC MinGW-w64 - # llvm-mingw does not support '-Wno-pedantic-ms-format' - if(CMAKE_C_COMPILER_ID MATCHES "GNU") + # Add `-Wno-pedantic-ms-format` only if the toolchain supports it + check_c_compiler_flag(-Wno-pedantic-ms-format HAVE_NO_PEDANTIC_MS_FORMAT) + if(HAVE_NO_PEDANTIC_MS_FORMAT) list(APPEND WARNFLAGS_DISABLE -Wno-pedantic-ms-format) endif() endif() -- 2.47.2