Simple Usage of C++20 Modules -- Victor Zverovich

SimpleUsage-Zverovich.jpgIn my previous post I showed how to compile {fmt} as a C++20 module with clang. Although taking only two commands, ideally it’s not something you should be doing manually. So in this post, I’ll talk about module support in CMake, everyone’s favorite not a build system.

Simple Usage of C++20 Modules

by Victor Zverovich

From the article:

My first attempt was to use the CMake’s built-in functionality advertised in “import CMake; C++20 Modules”. And after some struggle I made it to work with clang but unfortunately it was very limited. Here are some of the problems and limitations that I discovered:

  1. It only worked with ninja and while I don’t have anything against this build system it’s an extra hassle to get this additional dependency installed while make is usually available by default. This restriction also likely means that you cannot use such a CMake config with IDEs.
  2. Native CMake support only worked with clang 16 while the fmt module can be built manually with clang 15.
  3. It required the latest version of CMake and a lot of ceremony to set up, including some incomprehensible things.
  4. There were issues in dynamic dependency extraction both in clang-scan-deps and CMake itself.

 

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.