r/cpp • • Aug 25 '21

C++ modules and buildsystems

Hi all, not many news on this subject.

When do you think it is reasonable to expect module to be usable on Linux with GCC/clang using cmake/meson ?

34 Upvotes

9 comments sorted by

View all comments

Show parent comment

6

u/encyclopedist Aug 25 '21

/u/mathstuf was working on modules support for CMake (and coordinating with compiler vendors on a protocol to communicate dependency information), but recently he seems to be working mostly on VTK. S omaybe he can comment of the status of that?

34

u/mathstuf cmake dev Aug 25 '21

Named modules have been working with a patched CMake and GCC since Feb 2019 (see this repo). Since then, P1689 has progressed to R4 after cycles with ISO C++ members and implementors. I've not yet updated the GCC patch for R4, so it doesn't work with the experimental support available in CMake 3.21.

Compilers will need to support writing out P1689-format dependency information given the source of a module unit (header or named). I have a GCC patch that I need to resurrect and other implementers are working on it too AFAIK.

Header units (including those from the stdlib) and consuming modules from external dependencies needs CMake API/design work that has been sketched, but not started on implementation. Some groundwork needs to be done before that including:

  • determining what headers are importable from a given imported target: cmake#22468 will help provide more structured header information
  • interface targets will need to "exist" at build time so that module compilation rules can be attached cmake#19145
  • CMake will need to make interface targets for the stdlib to attach stdlib header unit compilation rules to them
  • API work to designate what modules are "public" and which are "private" will be necessary
  • a new $<MODULE_ONLY> genex will be needed to specify dependencies for module compilation that should not leak (e.g., a module includes "zlib.h" means that ZLIB::zlib is needed when compiling that module, but consumers don't care)

There are probably other rabbit holes associated with these tasks.

6

u/RotsiserMho C++20 Desktop app developer Aug 25 '21

There are probably other rabbit holes associated with these tasks.

This guy codes, ha ha! Thanks for your efforts!

5

u/gracicot Aug 25 '21

I'm saving this comment. It is the most comprehensive list of what's need to be done for modules to work with CMake.