C++ modules with CMake require recent C++ compilers.
The Ninja generator is required for C++ modules with CMake.
A fully working ball pit simulation shows more advanced use of C++ modules.
https://www.kitware.com/import-cmake-c20-modules/
https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html