How to use c++20 modules with CMake?

后端 未结 4 625
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 22:27

Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how?

I tried bui

4条回答
  •  旧巷少年郎
    2021-01-03 22:56

    CMake currently does not support C++20 modules.

    See also the relevant issue in the CMake issue tracker. Note that supporting modules requires far more support from the build system than inserting a new compiler option. It fundamentally changes how dependencies between source files have to be handled during the build: In a pre-modules world all cpp source files can be built independently in any order. With modules that is no longer true, which has implications not only for CMake itself, but also for the downstream build system.

    Take a look at the CMake Fortran modules paper for the gory details. From a build system's point of view, Fortran's modules behave very similar to the C++20 modules.

提交回复
热议问题