Skip to content

adityasz/cmake-cxx-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An example of using C++ Modules with CMake

I could not find good examples, so I wrote this.

If something is not right, send a patch.

This example has a library-based design:

.
├── CMakeLists.txt
├── modules
│   ├── example
│   │   ├── Greeter.ixx
│   │   └── Introducer.ixx
│   └── example.ixx
├── lib
│   ├── CMakeLists.txt
│   ├── Greeter
│   │   ├── CMakeLists.txt
│   │   └── Impl.cpp
│   └── Introducer
│       ├── CMakeLists.txt
│       ├── Impl.cpp
│       └── Internal.ixx
└── cli
    ├── CMakeLists.txt
    └── main.cpp

Note

GCC bug 122625 prevents me from using it. GCC 15.3 (unreleased) will have the fix. This project currently only supports clang. Tested only on Linux with clang 21.1 and CMake 3.31.6.

Modules are still experimental in CMake. See https://github.com/Kitware/CMake/blob/v${cmake_version}/Help/dev/experimental.rst and set CMAKE_EXPERIMENTAL_CXX_IMPORT_STD accordingly in the root CMakeLists.txt before using.

Warning

Even clang has issues.

About

An example of using C++ modules with CMake

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published