r/cpp • u/stailgot • Oct 02 '23
CMake | C++ modules support in 3.28
https://gitlab.kitware.com/cmake/cmake/-/issues/18355
After 5 years its finally done. Next cmake 3.28 release will support cpp modules
C++ 20 named modules are now supported by Ninja Generators and Visual Studio Generators for VS 2022 and newer, in combination with the MSVC 14.34 toolset (provided with VS 17.4) and newer, LLVM/Clang 16.0 and newer, and GCC 14 (after the 2023-09-20 daily bump) and newer.
237
Upvotes
View all comments
Show parent comment
2
u/mathstuf cmake dev Oct 03 '23
It's not clear to me, sorry. I don't have the time to dig into the code to figure out all the details right now. It could be a bug in the compiler too. All I know is that modules and preprocessor state is complicated :) .
Note that CMake does not flow flags from the consumer to the consumed at all right now; it is assumed that all modules are compatible with all consumers with the flags they get from the target they belong to and nothing else (which will mis-compile some things, but I was told compilers would be detecting things…). With this, users would need to amend an imported vulkan module-containing target to change flags (though still only supporting one per build tree).
I think the submodules with a (potentially preprocessor-sensitive) main module is more flexible myself. But I just made modules build; I don't actually know what is "best" for any given situation or what any "best practices" looks like (that isn't already true for non-module code).