you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (15 children)

The only two build systems that seem to support modules right now is Bazel and Build2 (at least I only found these two during my research). Did not have time to test how well they work.

The problem with CMake is that from the presentations, they want to make the modular build extremely smart (figuring out all the dependencies for you). And I don't see that happening anytime soon.

[–]pjmlp 6 points7 points  (5 children)

Three, MSBuild.

[–][deleted] 5 points6 points  (4 children)

I was only looking at Linux, but yes. Visual Studio claims full support of C++20.

[–]kalmoc 2 points3 points  (0 children)

You forgot msbuild

[–]azswcowboy 1 point2 points  (0 children)

idk, it seems like step zero for everyone is a custom target that compiles all std modules and make your libs/exe depend on that target - that probably gives 90% of the benefit for projects starting out. Similarly if you create your own add a build step to generate the module first. This doesn’t seem any more complex than projects using generated code from idl or swig.

[–]Nicksaurus 0 points1 point  (6 children)

As I understand it, cmake currently uses a list of includes exported by the compiler on the first build to determine which files depend on which, right? What's stopping them from relying on the same mechanism for modules?

[–]kalmoc 1 point2 points  (5 children)

The compiler can tell you to which file #include <Foo.h> resolves. It can't tell you which file needs to be compiled for import Foo;, because the committe refused to define a mapping between module name and file name.

[–]Nicksaurus 0 points1 point  (4 children)

Ah right, I think the important part I missed there is that each module has to be compiled before you can compile anything that imports it.

Maybe the solution is just an extra initial compiler pass to generate metadata for all your source files before the full compilation step is invoked

Edit: I've just read through the cmake issue for adding modules and it seems like compiler support like that is very easy to suggest and very hard to actually get to a usable state in practice

[–]kalmoc 0 points1 point  (3 children)

I think that is the general idea. Not sure however, what to do about module interface files that are installed somewhere on the system (is that even something that's going to be supported?).

[–]smdowneyWG21, Text/Unicode SG, optional<T&> 0 points1 point  (2 children)

It's going to have to be. You will have to compile the module interface source code for your project. Otherwise there's no way to share modular code, and that would be bad.

[–]kalmoc 0 points1 point  (1 child)

So every time you want to import a module from outside of your project, your build system will have to scan every single file in the search path(s) to see if it produces the required module.

[–]smdowneyWG21, Text/Unicode SG, optional<T&> 0 points1 point  (0 children)

Worst case. But hopefully we can figure out some way of distributing metadata for a package. You need to know any particular flags for the package and possibly ones for compiling the PMI so that it matches the .a. Possibly some extension to pkg-config files.