Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #287: cmake: Fix
TryAppendCXXFlags
module
634b3c7 fixup! cmake: Add `TryAppendCXXFlags` module (Hennadii Stepanov) ca8a111 fixup! cmake: Add compiler diagnostic flags (Hennadii Stepanov) 9bc8400 fixup! cmake: Add `TryAppendCXXFlags` module (Hennadii Stepanov) Pull request description: This PR fixes a couple of bugs in the `TryAppendCXXFlags` module that I noticed during testing on the staging branch: 1. Fixes the check of multiple flags. As documented, a space must be used as a separator:https://github.com/hebasto/bitcoin/blob/56450e50f0248969ff4688fc15e4f051c3b8cb65/cmake/module/TryAppendCXXFlags.cmake#L12-L14 Otherwise, only the first flag is actually being checked. Here are excerpts from `build/CMakeFiles/CMakeConfigureLog.yaml`: - on the staging branch @ 9256718: ``` kind: "try_compile-v1" backtrace: - "/usr/share/cmake-3.27/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)" - "/usr/share/cmake-3.27/Modules/CheckCXXSourceCompiles.cmake:52 (cmake_check_source_compiles)" - "cmake/module/TryAppendCXXFlags.cmake:70 (check_cxx_source_compiles)" - "CMakeLists.txt:416 (try_append_cxx_flags)" checks: - "Performing Test CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY" directories: source: "/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw" binary: "/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw" cmakeVariables: CMAKE_CXX_FLAGS: "" CMAKE_CXX_FLAGS_DEBUG: "-g" CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1" CMAKE_EXE_LINKER_FLAGS: "" CMAKE_MODULE_PATH: "/home/hebasto/git/bitcoin/cmake/module" CMAKE_POSITION_INDEPENDENT_CODE: "ON" buildResult: variable: "CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY" cached: true stdout: | Change Dir: '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw' Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_52a2c/fast /usr/bin/gmake -f CMakeFiles/cmTC_52a2c.dir/build.make CMakeFiles/cmTC_52a2c.dir/build gmake[1]: Entering directory '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw' Building CXX object CMakeFiles/cmTC_52a2c.dir/src.cxx.o /usr/bin/c++ -DCXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY -Wformat -std=c++20 -fPIC -o CMakeFiles/cmTC_52a2c.dir/src.cxx.o -c /home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw/src.cxx Linking CXX static library libcmTC_52a2c.a /usr/bin/cmake -P CMakeFiles/cmTC_52a2c.dir/cmake_clean_target.cmake /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_52a2c.dir/link.txt --verbose=1 /usr/bin/ar qc libcmTC_52a2c.a CMakeFiles/cmTC_52a2c.dir/src.cxx.o /usr/bin/ranlib libcmTC_52a2c.a gmake[1]: Leaving directory '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-8Q9qSw' exitCode: 0 ``` - with this PR: ``` kind: "try_compile-v1" backtrace: - "/usr/share/cmake-3.27/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)" - "/usr/share/cmake-3.27/Modules/CheckCXXSourceCompiles.cmake:52 (cmake_check_source_compiles)" - "cmake/module/TryAppendCXXFlags.cmake:70 (check_cxx_source_compiles)" - "CMakeLists.txt:416 (try_append_cxx_flags)" checks: - "Performing Test CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY" directories: source: "/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn" binary: "/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn" cmakeVariables: CMAKE_CXX_FLAGS: "" CMAKE_CXX_FLAGS_DEBUG: "-g" CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1" CMAKE_EXE_LINKER_FLAGS: "" CMAKE_MODULE_PATH: "/home/hebasto/git/bitcoin/cmake/module" CMAKE_POSITION_INDEPENDENT_CODE: "ON" buildResult: variable: "CXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY" cached: true stdout: | Change Dir: '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn' Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_ef70a/fast /usr/bin/gmake -f CMakeFiles/cmTC_ef70a.dir/build.make CMakeFiles/cmTC_ef70a.dir/build gmake[1]: Entering directory '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn' Building CXX object CMakeFiles/cmTC_ef70a.dir/src.cxx.o /usr/bin/c++ -DCXX_SUPPORTS__WFORMAT__WFORMAT_SECURITY -Wformat -Wformat-security -Werror -std=c++20 -fPIC -o CMakeFiles/cmTC_ef70a.dir/src.cxx.o -c /home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn/src.cxx Linking CXX static library libcmTC_ef70a.a /usr/bin/cmake -P CMakeFiles/cmTC_ef70a.dir/cmake_clean_target.cmake /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ef70a.dir/link.txt --verbose=1 /usr/bin/ar qc libcmTC_ef70a.a CMakeFiles/cmTC_ef70a.dir/src.cxx.o /usr/bin/ranlib libcmTC_ef70a.a gmake[1]: Leaving directory '/home/hebasto/git/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-SK4Pzn' exitCode: 0 ``` 2. Avoid skipping checks for linking due to caching of the `result` variable. The effect can be observed in the configuration output. ACKs for top commit: m3dwards: ACK 634b3c7 Tree-SHA512: 986f8efcff792f953cafb32d71e1e941303af0f03bc1187f0a371bdc5b950b4cf3764360fcc19fefae6464ac2ed4922b2a57da25d9d6df0d2135369b6c5d8cee
- Loading branch information