Use upstream patch to disable -Werror

This commit is contained in:
Tom Hughes 2018-01-15 22:49:43 +00:00
parent 023d7bc024
commit 1d4832d63d
2 changed files with 47 additions and 4 deletions

44
catch-werror.patch Normal file
View File

@ -0,0 +1,44 @@
commit 07c84adfbaac181560ed79576848fda82da6311b
Author: Martin Hořeňovský <martin.horenovsky@gmail.com>
Date: Sun Jan 14 18:14:11 2018 +0100
Allow disabling -Werror in CMake
Related to #1152
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fa91501..e0b2fc19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,7 @@ project(CatchSelfTest)
option(USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
option(BUILD_EXAMPLES "Build documentation examples" OFF)
option(ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
+option(DISABLE_WERROR "Do not enable warnings as errors" OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -309,7 +310,10 @@ if (NOT NO_SELFTEST)
# Add desired warnings
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
- target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Werror )
+ target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code )
+ if (NOT DISABLE_WERROR)
+ target_compile_options( SelfTest PRIVATE -Werror)
+ endif()
endif()
# Clang specific warning go here
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
@@ -318,7 +322,10 @@ if (NOT NO_SELFTEST)
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level
- target_compile_options( SelfTest PRIVATE /w44265 /WX /w44061 /w44062 )
+ target_compile_options( SelfTest PRIVATE /w44265 /w44061 /w44062 )
+ if (NOT DISABLE_WERROR)
+ target_compile_options( SelfTest PRIVATE /WX)
+ endif()
endif()

View File

@ -10,6 +10,8 @@ URL: https://github.com/philsquared/Catch
Source0: https://github.com/philsquared/Catch/archive/v%{version}/%{name}-%{version}.tar.gz
# https://github.com/catchorg/Catch2/commit/f0909dfe02df36e70c4c95ed00d53cb3eacf0262
Patch0001: 0001-Add-yet-another-expansion-of-INF-macro.patch
# https://github.com/catchorg/Catch2/commit/07c84adfbaac181560ed79576848fda82da6311b
Patch2: catch-werror.patch
BuildRequires: cmake make gcc-c++
BuildRequires: %{_bindir}/python3
@ -34,15 +36,12 @@ is packaged up as a single header for extra convenience.
%prep
%autosetup -p 1 -n Catch2-%{version}
# Putting -Werror always breaks when linters change and is bad for production
# https://github.com/catchorg/Catch2/issues/1152
sed -i -e "s|-Werror\([^=]\)|\1|" CMakeLists.txt
# No python, just python3
sed -i -e "s|COMMAND python |COMMAND %{_bindir}/python3 |" CMakeLists.txt
%build
%cmake . -Bbuild
%cmake . -Bbuild -DDISABLE_WERROR=ON
%make_build -Cbuild