Skip to content

c++modules: Default Module Support Breaks clang-tidy when gcc is used

Cmake has started passing module flags unconditionally to the compilers. While clang-tidy doesn't support it yet. This is on clang-tidy 18

https://gitlab.kitware.com/cmake/cmake/-/blob/v3.30.3/Modules/Compiler/GNU-CXX.cmake#L37

FAILED: my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o 
/opt/homebrew/Cellar/cmake/3.30.3/bin/cmake -E __run_co_compile --launcher=/opt/homebrew/bin/ccache --tidy="/Users/runner/llvm/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;--extra-arg-before=--driver-mode=g++" --source=/Users/runner/work/cpp_vcpkg_project/cpp_vcpkg_project/my_exe/test/tests.cpp -- /opt/homebrew/bin/g++-14 -DDO_NOT_USE_WMAIN -DCMAKE_INTDIR=\"Debug\" -I/Users/runner/work/cpp_vcpkg_project/cpp_vcpkg_project/my_exe/include -isystem /Users/runner/work/cpp_vcpkg_project/cpp_vcpkg_project/build/vcpkg_installed/arm64-osx/include -g -std=c++20 -arch arm64 -isysroot /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -fdiagnostics-color=always -Wall -Wextra -Wextra-semi -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast --coverage -O0 -g -MD -MT my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o -MF my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o.d -fmodules-ts -fmodule-mapper=my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o -c /Users/runner/work/cpp_vcpkg_project/cpp_vcpkg_project/my_exe/test/tests.cpp
error: unknown argument: '-fdeps-format=p1689r5' [clang-diagnostic-error]
error: unknown argument: '-fmodule-mapper=my_exe/test/CMakeFiles/my_exe_lib_tests.dir/Debug/tests.cpp.o.modmap' [clang-diagnostic-error]
error: unknown argument: '-fmodules-ts' [clang-diagnostic-error]

Possibly related to https://github.com/clangd/clangd/issues/662

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information