]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Detect -Wno-pedantic-ms-format support in mingw
authorHajin Jang <jb6804@naver.com>
Mon, 25 Sep 2023 17:15:10 +0000 (02:15 +0900)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 27 Sep 2023 22:15:12 +0000 (00:15 +0200)
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

index 6b53e8c8974026097543815b7758aae7f010f7e2..974af49ca5447932eaa1da744dec05d5d37c88ba 100644 (file)
@@ -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()