In 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:
- 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 whilemake
is usually available by default. This restriction also likely means that you cannot use such a CMake config with IDEs.- Native CMake support only worked with clang 16 while the fmt module can be built manually with clang 15.
- It required the latest version of CMake and a lot of ceremony to set up, including some incomprehensible things.
- There were issues in dynamic dependency extraction both in clang-scan-deps and CMake itself.
Add a Comment
Comments are closed.