[Modules] Dependency Generation


I am trying to create dependency files for a Makefile for modules TS.

$ cat bar.cppm
export module bar;
$ cat foo.cppm
export module foo;

import bar;
$ clang++ -MM -fmodules-ts foo.cppm
foo.cppm:3:8: fatal error: module 'bar' not found
import bar;
foo.o: foo.cppm
1 error generated.

Apparently I need to know, that foo imports bar and create a bar.pcm. Otherwise, I can not query the dependencies of foo?!?

Any ideas, how to create dependency files with modules-ts?


Exactly how to integrate build systems with modules TS (or the ATOM proposal) is a current source of discussion.

For now, with Clang, I don’t think there is a way to get dependency information from the compiler in a way akin to -MM. I’m not sure what Build2 is doing (the one public build system that’s got some support for modules) - maybe it’s doing its own scan of the source files looking for import lines.

  • Dave