CMake does not support C++20 modules with clang-cl.exe
Supplying CMAKE_CXX_COMPILER=clang-cl
with a target containing FILE_SET CXX_MODULES
does not work, and during configuration, CMake errors with:
CMake Error in CMakeLists.txt:
The target named "main" has C++ sources that may use modules, but the
compiler does not provide a way to discover the import graph dependencies.
See the cmake-cxxmodules(7) manual for details. Use the
CMAKE_CXX_SCAN_FOR_MODULES variable to enable or disable scanning.
clang-cl.exe
is in fact exactly (read: bit-for-bit equal, and therefore have equal file checksums) the same binary as clang.exe
in the official LLVM distribution for Windows, with only differing file names. It is able to forward arguments to the GNU-style driver with /clang:
, and therefore straightforwardly supports C++20 module compilation equally as well as the latter.
Edited by Sharadh Rajaraman