Fix cmake -DWARNINGS_AS_ERRORS=1 for clang

This commit is contained in:
Pawel Paruzel 2021-12-16 09:54:15 +01:00 committed by Vittorio Romeo
parent fbc866c5c9
commit aae00e9002

View File

@ -4,7 +4,12 @@
# Helper function to enable compiler warnings for a specific set of files
function(set_file_warnings)
if(APPLE)
# Temporarily disable Apple default until warnings are fixed
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE)
else()
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE)
endif()
set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
@ -69,17 +74,16 @@ function(set_file_warnings)
${NON_ANDROID_CLANG_AND_GCC_WARNINGS}
)
if(WARNINGS_AS_ERRORS)
set(CLANG_AND_GCC_WARNINGS ${CLANG_AND_GCC_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()
set(CLANG_WARNINGS
${CLANG_AND_GCC_WARNINGS}
-Wno-unknown-warning-option # do not warn on GCC-specific warning diagnostic pragmas
)
if(WARNINGS_AS_ERRORS)
set(CLANG_AND_GCC_WARNINGS ${CLANG_AND_GCC_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()
set(GCC_WARNINGS
${CLANG_AND_GCC_WARNINGS}
${NON_ANDROID_GCC_WARNINGS}