Skip to content

cmake: Disable automatic C++20 module dependency scanning - #355

Closed
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/cmake-nomodules
Closed

cmake: Disable automatic C++20 module dependency scanning#355
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/cmake-nomodules

Conversation

@ryanofsky

Copy link
Copy Markdown
Collaborator

Set CMAKE_CXX_SCAN_FOR_MODULES off because this project doesn't use C++ modules, and they are enabled by default in newer versions of cmake, which can lead to failures trying to invoke the clang-scan-deps tool if it is not installed.

… cmake policies

With latest cmake policies, specifically CMP0155, openbsd and freebsd CI
jobs fail due to a lack of a clang-scan-deps tool. The tool could
potentially be installed on these platforms but it is unclear how to do
that and the project isn't using modules anyway, so just disable them
here. Errors look like:

+ cmake --build . --parallel -t all tests mpexamples -- -k 0
[1/114] Scanning /home/runner/work/libmultiprocess/libmultiprocess/src/mp/util.cpp for CXX dependencies
FAILED: CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi
"CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" -format=p1689 -- /usr/bin/c++  -I/home/runner/work/libmultiprocess/libmultiprocess/include -I/home/runner/work/libmultiprocess/libmultiprocess/build-openbsd/include -isystem /usr/local/include -Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -std=gnu++20 -x c++ /home/runner/work/libmultiprocess/libmultiprocess/src/mp/util.cpp -c -o CMakeFiles/mputil.dir/src/mp/util.cpp.o -resource-dir "/usr/lib/clang/16" -MT CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi -MD -MF CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi.d > CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi.tmp && mv CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi.tmp CMakeFiles/mputil.dir/src/mp/util.cpp.o.ddi
/bin/sh: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found
@DrahtBot

DrahtBot commented Aug 20, 2026

Copy link
Copy Markdown

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

@maflcko

maflcko commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

-0
Seems odd to split this out when it can't happen in reality. Seems better to leave this as part of #209, so that review is easier.

Comment thread CMakeLists.txt
# Disable automatic C++20 module dependency scanning.
# CMake >=3.28 tries to use `clang-scan-deps` by default, which may not
# be installed on all platforms. We don't use named modules, so turn this off.
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

@hebasto hebasto Aug 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with @purpleKarrot and other CMake developers that a project should avoid forcibly setting the CMAKE_* variables as much as possible.

As far as I understand this is a workaround for an upstream bug reported here.

I think the proper workaround is to modify the CI scripts without touching the project's CML files.

If "we don't use named modules", we shouldn't worry about them at all rather than explicitly disabling them.

@hebasto

hebasto commented Aug 23, 2026

Copy link
Copy Markdown
Member

-0 Seems odd to split this out when it can't happen in reality. Seems better to leave this as part of #209, so that review is easier.

I agree. This change is a no-op on the current master branch.

@ryanofsky

Copy link
Copy Markdown
Collaborator Author

Good points. It's not good for the cmake file to force this setting internally when it could just be set by CI jobs that need it. And I didn't know there was an upstream bug reported for this https://gitlab.kitware.com/cmake/cmake/-/work_items/27228 so it might be fixed later. Will close this PR as it is not a good approach.

@ryanofsky ryanofsky closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants