From 955a5dd1b3f632394e3fe6bbd6a3442af0795e25 Mon Sep 17 00:00:00 2001 From: Chris Mumford Date: Tue, 15 Dec 2020 11:02:17 -0800 Subject: [PATCH] Building with `-Werror` only with clang. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc was unable to inline a function call, which caused a build failure due to `-Wall -Werror`. The build error was: ``` ../snappy.cc:292:76: error: ignoring attributes on template argument ā€˜__m128iā€™ [-Werror=ignored-attributes] 292 | static inline std::pair<__m128i /* pattern */, __m128i /* reshuffle_mask */> | ^ ../snappy.cc:292:76: error: ignoring attributes on template argument ā€˜__m128iā€™ [-Werror=ignored-attributes] cc1plus: all warnings being treated as errors ``` --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 868b5f0..48ae929 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,10 +66,13 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra") - # Use -Werror for clang and gcc. - if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") + # Use -Werror for clang only. + # There are many clang compiler ID's, but only one gcc. + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GCC") + if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") + endif(CMAKE_CXX_COMPILER_ID STREQUAL "GCC") # Disable C++ exceptions. string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")