Skip to content

Commit

Permalink
Unify werror flag (#423)
Browse files Browse the repository at this point in the history
* unfiy -Werror CMake & Makefile parameter between VVenC & VVdeC

* reduce code duplication by setting -Werror in toplevel Makefile
  • Loading branch information
K-os authored Sep 27, 2024
1 parent f2c3ee0 commit 0e7d4d3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down Expand Up @@ -217,6 +217,12 @@ if( VVENC_ENABLE_TRACING )
add_definitions( -DENABLE_TRACING=1 )
endif()

if( VVENC_ENABLE_WERROR )
add_compile_options( "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror>" )
add_compile_options( "$<$<CXX_COMPILER_ID:GNU>:-Werror>" )
add_compile_options( "$<$<CXX_COMPILER_ID:MSVC>:/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}" )
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
Expand Down
6 changes: 0 additions & 6 deletions source/App/vvencFFapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MI
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wall -fdiagnostics-show-option>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4100 /wd4244 /wd4251 /wd4459 /wd4996>)

if( NOT VVENC_SUPPRESS_WERROR )
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror>
$<$<CXX_COMPILER_ID:GNU>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
endif()

target_include_directories( ${EXE_NAME} PRIVATE ../../Lib )
target_link_libraries( ${EXE_NAME} Threads::Threads vvenc )
Expand Down
6 changes: 0 additions & 6 deletions source/App/vvencapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ set_target_properties( ${EXE_NAME} PROPERTIES MINSIZEREL_POSTFIX "${CMAKE_MI
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wall -fdiagnostics-show-option>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4244 /wd4251 /wd4996>)

if( NOT VVENC_SUPPRESS_WERROR )
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror>
$<$<CXX_COMPILER_ID:GNU>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
endif()

target_include_directories( ${EXE_NAME} PRIVATE ../../Lib )
target_link_libraries( ${EXE_NAME} Threads::Threads vvenc )
Expand Down
6 changes: 0 additions & 6 deletions source/Lib/vvenc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ include_directories( SYSTEM ../../../thirdparty )
add_compile_options( "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall;-Wno-deprecated-register;-Wno-unused-const-variable;-Wno-unknown-attributes>" )
add_compile_options( "$<$<CXX_COMPILER_ID:GNU>:-Wall;-Wno-unused-function;;-Wno-unused-variable;-Wno-sign-compare;-fdiagnostics-show-option;-Wno-ignored-attributes>" )
add_compile_options( "$<$<CXX_COMPILER_ID:MSVC>:/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( "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror>" )
add_compile_options( "$<$<CXX_COMPILER_ID:GNU>:-Werror>" )
add_compile_options( "$<$<CXX_COMPILER_ID:MSVC>:/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
Expand Down
6 changes: 3 additions & 3 deletions test/vvencinterfacetest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror -fdiagnostics-show-option>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /wd4100 /wd4244 /wd4251 /wd4996>)
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wall -fdiagnostics-show-option>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4100 /wd4244 /wd4251 /wd4996>)

target_link_libraries( ${EXE_NAME} vvenc )

Expand Down
4 changes: 2 additions & 2 deletions test/vvenclibtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror -fdiagnostics-show-option>
target_compile_options( ${EXE_NAME} PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wall -fdiagnostics-show-option>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /wd4244 /wd4251 /wd4996>)

target_link_libraries( ${EXE_NAME} Threads::Threads vvenc )
Expand Down

0 comments on commit 0e7d4d3

Please sign in to comment.