Skip to content

Commit

Permalink
cmake: Treat warnings as errors on Clang and GCC
Browse files Browse the repository at this point in the history
-Wformat-security is enabled, some Linux packages build system have it
enabled.
obsproject#5766

-Wunused-parameter is enabled too.

Also ensure that null conversion (C++ only for GCC) is enabled because its
enablement by default can depend on the CMake generator.

-Wno-error=deprecated-declarations is added on Linux/FreeBSD for release
builds to help packager.
  • Loading branch information
tytan652 committed Oct 2, 2022
1 parent 9f842aa commit 39ea8bc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmake/Modules/CompilerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,24 @@ else()
endif()

add_compile_options(
-Werror
-Wextra
-Wvla
-Wswitch
-Wformat
-Wformat-security
-Wunused-parameter
-Wno-unused-function
-Wno-missing-field-initializers
-fno-strict-aliasing
"$<$<COMPILE_LANGUAGE:C>:-Werror-implicit-function-declaration;-Wno-missing-braces>"
"$<$<BOOL:${USE_LIBCXX}>:-stdlib=libc++>"
"$<$<CONFIG:DEBUG>:-DDEBUG=1;-D_DEBUG=1>"
"$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:-fcolor-diagnostics>"
"$<$<COMPILE_LANG_AND_ID:C,AppleClang,Clang>:-fcolor-diagnostics>")
"$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:-Wnull-conversion;-fcolor-diagnostics>"
"$<$<COMPILE_LANG_AND_ID:C,AppleClang,Clang>:-Wnull-conversion;-fcolor-diagnostics>"
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wconversion-null>"
"$<$<AND:$<BOOL:${OS_POSIX}>,$<NOT:$<BOOL:${OS_MACOS}>>,$<NOT:$<CONFIG:DEBUG>>>:-Wno-error=deprecated-declarations>"
)

if(OBS_CODESIGN_LINKER)
add_link_options("LINKER:$<$<PLATFORM_ID:Darwin>:-adhoc_codesign>")
Expand Down

0 comments on commit 39ea8bc

Please sign in to comment.