For the purpose of checks performed by the build system, we strive to handle user-defined APPEND_*FLAGS
in the same way as flags provided by other standard means. In particular, they are considered when the try_compile()
command is used.
However, these flags are not considered during enable_language()
command invocation due to design limitations, which might cause issues, such as #32323.
This PR addresses the issue by introducing an additional compiler check that does consider the user-defined APPEND_*FLAGS
.
Fixes #32323:
0$ cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init"
1-- The CXX compiler identification is GNU 14.2.0
2-- Detecting CXX compiler ABI info
3-- Detecting CXX compiler ABI info - done
4-- Check for working CXX compiler: /usr/bin/c++ - skipped
5-- Detecting CXX compile features
6-- Detecting CXX compile features - done
7-- Performing Test CXX_COMPILER_WORKS
8-- Performing Test CXX_COMPILER_WORKS - Failed
9CMake Error at cmake/module/EnableLanguage.cmake:42 (message):
10 The CXX compiler is not able to compile a simple test program.
11
12 Check that the "APPEND_*FLAGS" variables are set correctly.
13
14
15
16Call Stack (most recent call first):
17 CMakeLists.txt:71 (bitcoincore_enable_language)
18
19
20-- Configuring incomplete, errors occurred!
21hebasto@TS-P340:~/dev/bitcoin$ cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero"
22-- Performing Test CXX_COMPILER_WORKS
23-- Performing Test CXX_COMPILER_WORKS - Success
24...