All module units are empty except for the imports as indicated in the comments above.
When compiling this project against Clang, I got
[13/14] Building CXX object CMakeFiles/my-lib.dir/mod6.cpp.o
/mnt/d/test/test-module/mod6.cpp:2:1: warning: it is deprecated to read module 'mod1' implicitly; it is going to be removed in clang 18; consider to specify the dependencies explicitly [-Wread-modules-implicitly]
2 | import mod5;
| ^
1 warning generated.
warning: it is deprecated to read module 'mod1' implicitly; it is going to be removed in clang 18; consider to specify the dependencies explicitly [-Wread-modules-implicitly]
1 warning generated.
It seems that CMake forgets to tell Clang the location of mod1.pcm when compiling mod6.cpp.
Note that the order of files in target_souces is significant. The warning might not occur if the files are listed in a different order.
Does this sound like a bug of CMake? Is this a known bug?
For the reference, here are the contents of `mod1.cpp` through `mod6.cpp`
bash-5.2$ ninja Algo -j 1
[4/6] Building CXX object CMakeFiles/Algo.dir/algo-interface.cppm.o
warning: it is deprecated to read module 'fmt' implicitly; it is going to be removed in clang 18; consider to specify the dependencies explicitly [-Wread-modules-implicitly]
1 warning generated.
[5/6] Building CXX object CMakeFiles/Algo.dir/algo-impl.cpp.o
warning: the form '-fmodule-file=<BMI-path>' is deprecated for standard C++ named modules;consider to use '-fmodule-file=<module-name>=<BMI-path>' instead [-Weager-load-cxx-named-modules]
warning: the form '-fmodule-file=<BMI-path>' is deprecated for standard C++ named modules;consider to use '-fmodule-file=<module-name>=<BMI-path>' instead [-Weager-load-cxx-named-modules]
/Users/clausklein/Workspace/cpp/cxx20/cmake-init-modules/algo-impl.cpp:6:1: warning: it is deprecated to read module 'fmt' implicitly; it is going to be removed in clang 18; consider to specify the dependencies explicitly [-Wread-modules-implicitly]
6 | module algo;
| ^
3 warnings generated.
[6/6] Linking CXX shared library libAlgo.dylib
bash-5.2$
bash-5.2$ cmake --version
cmake version 3.29.20240409-g24f1e7c
CMake suite maintained and supported by Kitware (kitware.com/cmake).
bash-5.2$ clang --version
Homebrew clang version 17.0.6
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
bash-5.2$
I don’t see your build scanning the fmt module. You cannot use BMI files not compiled as part of the project. It seems that fmt is not being provided as an IMPORTED target with CXX_MODULES-typed FILE_SET sources to let CMake know about its modules.