cmake: Disable automatic C++20 module dependency scanning - #355
Conversation
… 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
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process. |
|
-0 |
| # 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) |
There was a problem hiding this comment.
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.
I agree. This change is a no-op on the current master branch. |
|
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. |
Set
CMAKE_CXX_SCAN_FOR_MODULESoff 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 theclang-scan-depstool if it is not installed.