clang-tidy CXX modules on Windows
Is clang-tidy on Windows (aka cl.exe) supposed to work when module are enabled but there is no module in the target? I have seen different ways of triggering this error and I don't know enough to know if it is just tools (cl.exe, clang-tidy, cmake) not there yet or an issue.
Here is the error:
"C:\Program Files\CMake\bin\cmake.exe" -E __run_co_compile --tidy="C:/Program Files/LLVM/bin/clang-tidy.exe;-extra-arg=-Wno-unknown-warning-option;-extra-arg=-Wno-ignored-optimization-argument;-extra-arg=-Wno-unused-command-line-argument;-p;-extra-arg=/std:c++23;--extra-arg-before=--driver-mode=cl" --source=D:\_Dev\Projects\PersonalWorks\Projects\TestUtilities\TestUtilities\BasicTestsGenerator.cpp -- C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1440~1.336\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -DTESTUTILITIES_STATIC_DEFINE -ID:\_Dev\Projects\PersonalWorks\Projects\TestUtilities -ID:\_Dev\Projects\PersonalWorks\_Out\build\Windows-Msvc-Ninja-Debug\Projects\TestUtilities -external:ID:\_Dev\Projects\PersonalWorks\_Out\vcpkg_installed\x64-windows\include -external:W0 /EHsc /MP /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /GL /MP /diagnostics:column /sdl /DYNAMICBASE /guard:cf /W4 /w14242 /w14254 /w14263 /w14265 /w14287 /we4289 /w14296 /w14311 /w14545 /w14546 /w14547 /w14549 /w14555 /w14619 /w14640 /w14826 /w14905 /w14906 /w14928 /permissive- /showIncludes @Projects\TestUtilities\CMakeFiles\TestUtilities.dir\TestUtilities\BasicTestsGenerator.cpp.obj.modmap /FoProjects\TestUtilities\CMakeFiles\TestUtilities.dir\TestUtilities\BasicTestsGenerator.cpp.obj /FdProjects\TestUtilities\CMakeFiles\TestUtilities.dir\TestUtilities.pdb /FS -c D:\_Dev\Projects\PersonalWorks\Projects\TestUtilities\TestUtilities\BasicTestsGenerator.cpp
error: no such file or directory: '@Projects\TestUtilities\CMakeFiles\TestUtilitiesGBenchmark.dir\TestUtilities\BasicTestsGenerator.cpp.obj.modmap' [clang-diagnostic-error]
error: no such file or directory: '@Projects\TestUtilities\CMakeFiles\TestUtilitiesTestsGTest.dir\TestUtilities\BasicTestsGenerator.cpp.obj.modmap' [clang-diagnostic-error]
Error while processing D:\_Dev\Projects\PersonalWorks\Projects\TestUtilities\TestUtilities\BasicTestsGenerator.cpp.
Error while processing D:\_Dev\Projects\PersonalWorks\Projects\TestUtilities\TestUtilities\BasicTestsGenerator.cpp.
This caught my eye, the "@" made me thing something is wrong here.
@Projects\TestUtilities\CMakeFiles\TestUtilities.dir\TestUtilities\BasicTestsGenerator.cpp.obj.modmap
What I think is relevant here (I might be wrong) is how I set the target sources. This target doesn't have any modules. (But I do have a function that does all the right CMake call so other targets could have modules. I am assuming it is valid to pass an empty FILE_SET.
set(moduleFiles
)
target_sources(${targetName}
PRIVATE ${privateFiles}
PUBLIC
FILE_SET CXX_MODULES FILES ${moduleFiles}
##PUBLIC
##FILE_SET CXX_MODULE_HEADER_UNITS FILES ${headerUnitFiles}
PUBLIC ${publicFiles}
INTERFACE ${interfaceFiles}
)
At first I thought the issue was empty modmap, then I saw this one.
"C:\Program Files\CMake\bin\cmake.exe" -E __run_co_compile --tidy="C:/Program Files/LLVM/bin/clang-tidy.exe;-extra-arg=-Wno-unknown-warning-option;-extra-arg=-Wno-ignored-optimization-argument;-extra-arg=-Wno-unused-command-line-argument;-p;-extra-arg=/std:c++23;--extra-arg-before=--driver-mode=cl" --source=D:\_Dev\Projects\PersonalWorks\Projects\Core\Core\CoreUtility.ixx -- C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1440~1.336\bin\Hostx64\x64\cl.exe /nologo /TP -DCORE_STATIC_DEFINE -DFMT_SHARED -DTESTUTILITIES_STATIC_DEFINE -ID:\_Dev\Projects\PersonalWorks\Projects\Core -ID:\_Dev\Projects\PersonalWorks\_Out\build\Windows-Msvc-Ninja-Debug\Projects\Core -ID:\_Dev\Projects\PersonalWorks\_Out\build\Windows-Msvc-Ninja-Debug\Projects\Config -ID:\_Dev\Projects\PersonalWorks\Projects\TestUtilities -ID:\_Dev\Projects\PersonalWorks\_Out\build\Windows-Msvc-Ninja-Debug\Projects\TestUtilities -external:ID:\_Dev\Projects\PersonalWorks\_Out\vcpkg_installed\x64-windows\include -external:W0 /EHsc /MP /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /GL /MP /diagnostics:column /sdl /DYNAMICBASE /guard:cf /W4 /w14242 /w14254 /w14263 /w14265 /w14287 /we4289 /w14296 /w14311 /w14545 /w14546 /w14547 /w14549 /w14555 /w14619 /w14640 /w14826 /w14905 /w14906 /w14928 /permissive- /showIncludes @Projects\Core\CMakeFiles\Core.dir\Core\CoreUtility.ixx.obj.modmap /FoProjects\Core\CMakeFiles\Core.dir\Core\CoreUtility.ixx.obj /FdProjects\Core\CMakeFiles\Core.dir\Core.pdb /FS -c D:\_Dev\Projects\PersonalWorks\Projects\Core\Core\CoreUtility.ixx
error: no such file or directory: 'Projects\Core\CMakeFiles\Core.dir\CoreUtility.ifc' [clang-diagnostic-error]
Error while processing D:\_Dev\Projects\PersonalWorks\Projects\Core\Core\CoreUtility.ixx.
Which is not empty
-interface
-ifcOutput Projects\Core\CMakeFiles\Core.dir\CoreUtility.ifc
So now I am confused, and think that clang-tidy just can't read modmaps? Also that "@" in the cmd line is it right?
Though I can't give cmd line ( I don't have them anymore), I managed to get the same errors with Clang and Clang-tidy on Linux It might have been: Ubuntu noble with default cmake and default Clang from the distribution, but I am not sure.
Thanks
p.s. I see this on cmake 3.28.1 and the just released 3.29