From a619943001b83c227f144beb64122f0a9ba17c23 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 4 Aug 2020 11:08:03 -0400 Subject: [PATCH] Build: Make things build with clang without needing local changes Useful for sanitizer fuzzer builds. clang doesn't have a -fconcepts switch (I'm guessing it just enables concepts automatically with -std=c++2a, but I haven't checked), and at least the version on my system doesn't understand -Wno-deprecated-move, so pass these two flags only to gcc. In return, disable -Woverloaded-virtual which fires in many places. The preceding commits fixed the handful of -Wunused-private-field warnings that clang emitted. --- CMakeLists.txt | 7 ++++++- Meta/Lagom/CMakeLists.txt | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 713b1a263d..f434a71a5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,12 @@ add_custom_target(check-style USES_TERMINAL ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -std=c++2a -fdiagnostics-color=always -fconcepts") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++2a -fdiagnostics-color=always") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconcepts") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +endif() include_directories(Libraries) include_directories(.) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index b0bb13d242..9562d18513 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required (VERSION 3.0) project (Lagom) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wextra -Werror -std=c++2a -fPIC -g -Wno-deprecated-copy") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wextra -Werror -std=c++2a -fPIC -g") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") +endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconsumed") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconsumed -Wno-overloaded-virtual") option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" FALSE) if (ENABLE_ADDRESS_SANITIZER)