mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2026-10-28 16:18:23 +08:00
The compiler is fixed (Clang with a known minimum version, see `cmake/tools.cmake`)
and so are the vendored sysroots, so probes like `check_cxx_source_compiles`,
`check_function_exists`, `check_include_file`, `try_compile`, etc. are
unnecessary - the answer is known statically. They are also slow,
non-deterministic, and a source of build divergence between machines.
This change:
* Rewrites `cmake/add_warning.cmake` so that `add_warning` / `no_warning` /
`target_add_warning` / `target_no_warning` simply append the flag.
Previously they used `check_cxx_compiler_flag` / `check_c_compiler_flag` to
feature-test every `-W` flag at configure time.
* Hard-codes clang-version-specific warnings in `cmake/warnings.cmake`. The
`lifetime-safety-*` warnings only exist in clang 23+, so they are now gated
on `CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 23` instead of being
detected.
* Deletes the empty `cmake/check_flags.cmake` stub.
* Adds `cmake/block_build_time_checks.cmake`, included before
`add_subdirectory(contrib)`, which installs `FATAL_ERROR` overrides for
every `check_*` macro/function plus `try_compile` / `try_run`. Even when a
`CheckCXXCompilerFlag`-style module re-defines its wrapper, the call still
funnels through the overridden `try_compile` and aborts with a clear
message pointing at this file. Where compiler-version-specific behaviour is
genuinely required, gate it on `CMAKE_CXX_COMPILER_VERSION` instead.
* Removes the two real probe call-sites in contrib `*-cmake/`:
- `contrib/mongo-c-driver-cmake`: `test_big_endian(BSON_BIG_ENDIAN)` ->
static check on `ARCH_S390X` (only big-endian arch we support).
- `contrib/isa-l-cmake`: `check_language(ASM_NASM)` ->
`set(CMAKE_ASM_NASM_COMPILER \${NASM_PATH})` using the path already found
by `find_program`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25 lines
924 B
CMake
25 lines
924 B
CMake
# Append -W${flag} to the compile flags.
|
|
#
|
|
# Historically these macros invoked `check_cxx_compiler_flag` to probe the compiler at configure
|
|
# time. We have removed all such build-time checks: the project requires Clang of a known minimum
|
|
# version (see `cmake/tools.cmake`), so the set of supported warning flags is fixed and known
|
|
# statically. The right place to gate version-specific warnings is `cmake/warnings.cmake`,
|
|
# behind an explicit `CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL N` guard.
|
|
|
|
macro (add_warning flag)
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${flag}")
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W${flag}")
|
|
endmacro ()
|
|
|
|
macro (no_warning flag)
|
|
add_warning(no-${flag})
|
|
endmacro ()
|
|
|
|
macro (target_add_warning target flag)
|
|
target_compile_options (${target} PRIVATE "-W${flag}")
|
|
endmacro ()
|
|
|
|
macro (target_no_warning target flag)
|
|
target_add_warning(${target} no-${flag})
|
|
endmacro ()
|