r/cpp • u/holyblackcat • Mar 09 '26
The compilation procedure for C++20 modules
https://holyblackcat.github.io/blog/2026/03/09/compiling-modules.html
103
Upvotes
r/cpp • u/holyblackcat • Mar 09 '26
View all comments
Show parent comment
9
u/not_a_novel_account cmake dev Mar 09 '26
You can. See C++20 Modules: Best Practices from a User's Perspective.
The standard doesn't outline how this is supposed to work, because nominally the standard assumes every partition exports something, but the toolchains don't care about this.
There's a small bit of waste in CMake usage because CMake will still generate a BMI even though we're only building the code for the object file output. This is because CMake believes the standard when it says these partition units are supposed to export something.
I'm working on a paper to fix the awkwardness of this pattern on both the language and build system side.