How to use VC ++ modules in CMake

MS Visual C ++ 2015 Update 1 implements a proposal of modules .

Here is an example of how this works:
Sources:

// c.ixx | // b.ixx | // a.cpp module GM; | import GM; | import FM; export void g() {} | module FM; | int main() { f(); } | export void f() { g(); } | 

Build Commands:

 set CL=/EHsc /experimental:module # Default flags for cl.exe cl.exe /c c.ixx # Produces c.obj, GM.ifc cl.exe /c b.ixx # Depends on GM.ifc, produces b.obj, FM.ifc cl.exe /c a.cpp # Depends on FM.ifc, produces a.obj link.exe a.obj b.obj c.obj # Produces a.exe 

Dependency Graph:

 c.ixxGM.ifcb.ixxFM.ifca.cpp ↘ ↓ ↙ c.obj b.obj a.obj ↘ ↓ ↙ a.exe 

Each module has one file.ixx with its export.
This file will be compiled into ModuleName.ifc and file.obj .

If the file imports the M module, the M.ifc file must be present.
By default, cl.exe searches for .ifc files in the current directory, but you can specify explicit names or a search path:

 cl.exe /c a.cpp -- or -- cl.exe /c a.cpp /module:reference FM.ifc -- or -- cl.exe /c a.cpp /module:search ./ 

So the question is: How to use the implementation of VC ++ modules in CMake ?
No need to use the MSBuild backend, the ninja is fine too.

+7
c ++ visual-c ++ cmake c ++ - modules
source share
1 answer

I do not believe that at this time someone did any work with the build system for C ++ modules. We (Microsoft) will probably support MSBuild first, but CMake is definitely an option.

0
source share

All Articles