From 0e7d4d34b00eedfccc79a3014f9701ae3599dcc0 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 27 Sep 2024 12:25:28 +0200 Subject: [PATCH] Unify werror flag (#423) * unfiy -Werror CMake & Makefile parameter between VVenC & VVdeC * reduce code duplication by setting -Werror in toplevel Makefile --- CMakeLists.txt | 8 +++++++- Makefile | 4 ++-- source/App/vvencFFapp/CMakeLists.txt | 6 ------ source/App/vvencapp/CMakeLists.txt | 6 ------ source/Lib/vvenc/CMakeLists.txt | 6 ------ test/vvencinterfacetest/CMakeLists.txt | 6 +++--- test/vvenclibtest/CMakeLists.txt | 4 ++-- 7 files changed, 14 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4aebe348a..0545841ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ set( VVENC_ENABLE_THIRDPARTY_JSON ON CACHE BOOL "Enable use of thir set( VVENC_INSTALL_FULLFEATURE_APP OFF CACHE BOOL "Install the full-feature app: vvencFFapp" ) -set( VVENC_SUPPRESS_WERROR OFF CACHE BOOL "Suppress treating all compile warnings as errors" ) +set( VVENC_ENABLE_WERROR ON CACHE BOOL "Treat warnings as errors (-Werror or /WX)" ) if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) @@ -217,6 +217,12 @@ if( VVENC_ENABLE_TRACING ) add_definitions( -DENABLE_TRACING=1 ) endif() +if( VVENC_ENABLE_WERROR ) + add_compile_options( "$<$,$>:-Werror>" ) + add_compile_options( "$<$:-Werror>" ) + add_compile_options( "$<$:/WX>" ) +endif() + if( VVENC_ENABLE_X86_SIMD ) if( ( UNIX OR MINGW ) AND VVENC_OPT_TARGET_ARCH ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${VVENC_OPT_TARGET_ARCH} -mtune=${VVENC_OPT_TARGET_ARCH}" ) diff --git a/Makefile b/Makefile index 8d6cc0115..84abbf6ca 100644 --- a/Makefile +++ b/Makefile @@ -78,8 +78,8 @@ ifneq ($(override-compiler-check),) CONFIG_OPTIONS += -DVVENC_OVERRIDE_COMPILER_CHECK=$(override-compiler-check) endif -ifneq ($(suppress-werror),) -CONFIG_OPTIONS += -DVVENC_SUPPRESS_WERROR=$(suppress-werror) +ifneq ($(enable-werror),) +CONFIG_OPTIONS += -DVVENC_ENABLE_WERROR=$(enable-werror) endif ifeq ($(j),) diff --git a/source/App/vvencFFapp/CMakeLists.txt b/source/App/vvencFFapp/CMakeLists.txt index d6a5e0867..99ac6f063 100644 --- a/source/App/vvencFFapp/CMakeLists.txt +++ b/source/App/vvencFFapp/CMakeLists.txt @@ -32,12 +32,6 @@ set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MI target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall> $<$:-Wall -fdiagnostics-show-option> $<$:/W4 /wd4100 /wd4244 /wd4251 /wd4459 /wd4996>) - -if( NOT VVENC_SUPPRESS_WERROR ) - target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Werror> - $<$:-Werror> - $<$:/WX>) -endif() target_include_directories( ${EXE_NAME} PRIVATE ../../Lib ) target_link_libraries( ${EXE_NAME} Threads::Threads vvenc ) diff --git a/source/App/vvencapp/CMakeLists.txt b/source/App/vvencapp/CMakeLists.txt index 2aee4bff5..c63900354 100644 --- a/source/App/vvencapp/CMakeLists.txt +++ b/source/App/vvencapp/CMakeLists.txt @@ -29,12 +29,6 @@ set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MI target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall> $<$:-Wall -fdiagnostics-show-option> $<$:/W4 /wd4244 /wd4251 /wd4996>) - -if( NOT VVENC_SUPPRESS_WERROR ) - target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Werror> - $<$:-Werror> - $<$:/WX>) -endif() target_include_directories( ${EXE_NAME} PRIVATE ../../Lib ) target_link_libraries( ${EXE_NAME} Threads::Threads vvenc ) diff --git a/source/Lib/vvenc/CMakeLists.txt b/source/Lib/vvenc/CMakeLists.txt index 37d41fb88..ca8ddac0e 100644 --- a/source/Lib/vvenc/CMakeLists.txt +++ b/source/Lib/vvenc/CMakeLists.txt @@ -82,12 +82,6 @@ include_directories( SYSTEM ../../../thirdparty ) add_compile_options( "$<$,$>:-Wall;-Wno-deprecated-register;-Wno-unused-const-variable;-Wno-unknown-attributes>" ) add_compile_options( "$<$:-Wall;-Wno-unused-function;;-Wno-unused-variable;-Wno-sign-compare;-fdiagnostics-show-option;-Wno-ignored-attributes>" ) add_compile_options( "$<$:/W4;/wd4100;/wd4127;/wd4244;/wd4245;/wd4251;/wd4310;/wd4389;/wd4456;/wd4457;/wd4458;/wd4459;/wd4505;/wd4701;/wd4702;/wd4703;/wd4996>" ) - -if( NOT VVENC_SUPPRESS_WERROR ) - add_compile_options( "$<$,$>:-Werror>" ) - add_compile_options( "$<$:-Werror>" ) - add_compile_options( "$<$:/WX>" ) -endif() # don't export all symbols from shared libraries by default (gcc: -fvisibility=hidden), only those marked as VVENC_DECL # behavior similar to __declspec(dllexport) on windows diff --git a/test/vvencinterfacetest/CMakeLists.txt b/test/vvencinterfacetest/CMakeLists.txt index 21059ece8..8749b66ef 100644 --- a/test/vvencinterfacetest/CMakeLists.txt +++ b/test/vvencinterfacetest/CMakeLists.txt @@ -19,9 +19,9 @@ set_target_properties( ${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DE set_target_properties( ${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}" ) set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}" ) -target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Werror> - $<$:-Wall -Werror -fdiagnostics-show-option> - $<$:/W4 /WX /wd4100 /wd4244 /wd4251 /wd4996>) +target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall> + $<$:-Wall -fdiagnostics-show-option> + $<$:/W4 /wd4100 /wd4244 /wd4251 /wd4996>) target_link_libraries( ${EXE_NAME} vvenc ) diff --git a/test/vvenclibtest/CMakeLists.txt b/test/vvenclibtest/CMakeLists.txt index 4e7f91131..1c633d62e 100644 --- a/test/vvenclibtest/CMakeLists.txt +++ b/test/vvenclibtest/CMakeLists.txt @@ -19,8 +19,8 @@ set_target_properties( ${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DE set_target_properties( ${EXE_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}" ) set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}" ) -target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall -Werror> - $<$:-Wall -Werror -fdiagnostics-show-option> +target_compile_options( ${EXE_NAME} PRIVATE $<$,$>:-Wall> + $<$:-Wall -fdiagnostics-show-option> $<$:/W4 /WX /wd4244 /wd4251 /wd4996>) target_link_libraries( ${EXE_NAME} Threads::Threads vvenc )