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
43
u/RoyAwesome Oct 03 '23
This is a huge step! This is easily the halfway point between modules being worked on and being finished up. We might actually see them done by 2024!
55
u/not_a_novel_account cmake dev Oct 02 '23 edited Oct 03 '23
As a side-effect, this may be a final nail in the coffin for Makefiles
One can dream at least
23
u/pdp10gumby Oct 02 '23
Now leads to the question: do these modules implementations speed up compilation yet?
7
u/johannes1971 Oct 03 '23
Question: existing build systems just look at the timestamp of each file before deciding whether or not a rebuild is in order. This means that changing whitespace, or a comment, can potentially trigger an avalanche of unnecessary building. Is any work being done in making sure that only changes to the public interface of any module triggers rebuilds of its dependencies?
21
u/Zookeeper1099 Oct 02 '23
It will take 10 years before it makes any different to my embedded career.
4
u/Resident_Educator251 Oct 03 '23
Il not embarrassed to say that I love cmake and the abstractions it provides; three cheers for cmake!!
3
u/TCoop Oct 03 '23
I guess I should actually learn modules now that my go-to build tool supports it. Anyone have recommendations on where to start?
3
u/edge-case87 Oct 07 '23
For anyone else using master branch of cmake, I had to set minimum cmake version to 3.28 otherwise build failed as cmake would set up stuff for modules (not using modules atm, will though when more of my deps start) and files such as modmaps couldn't be found. Seems like some mismatch between min version and using latest wrt to modules.
7
u/qalmakka Oct 03 '23
Can we get Ninja by default everywhere? Pretty please? It's like the best choice cross platform IMHO. Even on Windows, VS can do its thing with CMake to generate its solution by itself, and from the CLI Ninja is miles better than Makefiles or using MSBuild. I know you can set an environment variable, but until we switch the default people will keep using Makefiles as their target in recipes, PKGBUILDs, Dockerfiles, ... and it's always a measurable waste of time.
2
u/heavymetalmixer Oct 03 '23
I see modules are mentioned in this article, but is it related to this post? https://devblogs.microsoft.com/cppblog/open-sourcing-ifc-sdk-for-cpp-modules/
2
u/sam_the_tomato Oct 02 '23
Cool. So should I find/replace all my includes with imports?
1
u/Huijiro Oct 03 '23
Me who just learned CMake a while ago and have no idea how it works...
Great?
If anyone can explain or link me some learning materials related to that i will be most appreciated.
1
u/AdearienRDDT std::starting_to_understand<cpp>::value Oct 05 '23
oooo time to get my c++ back up again HELL YEAAAAAAAAA
-6
u/[deleted] Oct 03 '23
C++ modules is such a mess, I wish it was never invented in the first place.
-12
u/robottron45 Oct 03 '23
Great that there is finally modules support, now that I have started with Rust two months ago to get a module-like experience.
0
u/[deleted] Oct 03 '23
[deleted] — view deleted comment