Use /std:clatest with MSVC, remove -Wunused-result
Use -std=gnu2x with Clang and GCC only. Use Use /std:clatest with MSVC.
Remove -Wunused-result. Clang and GCC enable it by default, and MSVC
doesn't support it.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 381237d..21aee88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -324,9 +324,12 @@
else()
unset(CMAKE_C_STANDARD)
set_property(TARGET avif_obj PROPERTY C_STANDARD)
- target_compile_options(avif_obj PUBLIC $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C>:-std=gnu2x>>)
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
+ target_compile_options(avif_obj PUBLIC $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C>:-std=gnu2x>>)
+ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
+ target_compile_options(avif_obj PUBLIC $<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C>:/std:clatest>>)
+ endif()
endif()
- target_compile_options(avif_obj PUBLIC $<BUILD_INTERFACE:-Wunused-result>)
target_compile_definitions(avif_obj PUBLIC $<BUILD_INTERFACE:AVIF_ENABLE_NODISCARD=1>)
endif()