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.
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()