diff --git a/CMakeLists.txt b/CMakeLists.txt index c6a1482f..93654055 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ project(s2-geometry VERSION 0.12.0) include(CMakeDependentOption) -include(CheckCXXCompilerFlag) include(FeatureSummary) include(FetchContent) include(FindPackageHandleStandardArgs) @@ -123,19 +122,21 @@ else() # util/math/vector.h:178:16: warning: optimization attribute on # ‘double sqrt(double)’ follows definition but the attribute doesn’t # match [-Wattributes] - add_definitions(-Wno-attributes) - add_definitions(-Wno-deprecated-declarations) - add_definitions(-Wno-nullability-completeness) + add_compile_options($<$:-Wno-attributes>) + add_compile_options($<$:-Wno-deprecated-declarations>) + add_compile_options($<$:-Wno-sign-compare>) + add_compile_options($<$:-Wno-nullability-completeness>) # Suppress noisy AArch64 ABI notes about parameter passing changes in # GCC 10.1. Irrelevant since we don't mix objects from old compilers. - # TODO: Use check_cxx_compiler_flag(-Wno-psabi) to guard this. - add_compile_options(-Wno-psabi) + add_compile_options($<$:-Wno-psabi>) # Some files use sized deallocation, which should be enabled by # default for C++14 and later. There appears to be a bug with clang # < 19 causing this not to be enabled. # https://github.com/google/s2geometry/issues/411#issuecomment-2726949607 # This can be removed when clang19 is the minimum supported version. - add_compile_options(-fsized-deallocation) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options($<$:-fsized-deallocation>) + endif() endif() # If OpenSSL is installed in a non-standard location, configure with diff --git a/src/.bazelrc b/src/.bazelrc index 145802fd..e79fd655 100644 --- a/src/.bazelrc +++ b/src/.bazelrc @@ -3,10 +3,28 @@ common --enable_bzlmod common --cxxopt=-std=c++20 common --announce_rc +# C++ warning flags for non-MSVC toolchains. Keep in line with CMakeLists.txt. +# `bazel test --config=ci` uses `build:ci --config=gcc` (Linux CI). For local +# macOS / Clang builds, pass `--config=clang` in addition to your other flags. + +# Host GCC (Linux CI). +build:gcc --cxxopt=-Wno-attributes +build:gcc --cxxopt=-Wno-deprecated-declarations +build:gcc --cxxopt=-Wno-sign-compare +build:gcc --cxxopt=-Wno-psabi + +# Clang (e.g. macOS). +build:clang --cxxopt=-Wno-attributes +build:clang --cxxopt=-Wno-deprecated-declarations +build:clang --cxxopt=-Wno-sign-compare +build:clang --cxxopt=-Wno-nullability-completeness +build:clang --cxxopt=-fsized-deallocation + # Faster tests than fastbuild (-O0). build:dev --copt=-O1 -# CI-specific flags +# CI-specific flags. common:ci --color=yes +build:ci --config=gcc build:ci --show_progress_rate_limit=10 test:ci --test_output=errors