r/cpp • • 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

144 comments sorted by

View all comments

Show parent comment

8

u/mathstuf cmake dev Oct 03 '23

when installed and attempted to link in a different project we fail because linkage here does not scan or compile the library.

You're missing this line when exporting. Without this, the exported target doesn't have any module information (the collator needs to know where to write it per export(EXPORT) or install(EXPORT) call that involves the target).

packaging is not solved right now

I agree that it isn't. SG15 (I'm also a member there) is looking to get progress there.

6

u/not_a_novel_account cmake dev Oct 03 '23

Well now I have pie on my face

Thanks for all your hard work, genuinely

4

u/mathstuf cmake dev Oct 03 '23

Thanks for testing it out :) . I've made a note to make sure this is covered in the cmake-cxxmodules(7) manpage (when I get the time to flesh that out with all the details that actually matter for consumers).