This is a small template project setup showing the use of C++20 Modules and CMake. It includes:
- 2 libraries as C++20 Modules -
maths
andutils
- a simple
main.cc
that consumes themaths
module
Anyway. It isn't a full setup|template yet, but I'll work on adding more stuff [docs, testing, linting, formatting, etc.]
- vcpkg with the
VCPKG_ROOT
environment variable set up - Lastet CMake version [3.30.3]
clang++
19.1 - see The LLVM Project- PS:
g++
didn't play well with the private module fragment and theimport
keyword in general :(
- PS:
As of now, if you have cmake, vcpkg and clang++ set up, i.e. you should be able to build the project with a single command by making use of CMake Presets:
cmake --workflow --preset lnx-config-build-dbg
or
cmake --workflow --preset lnx-config-build-rel
- Add Doxygen for Documentation
- Figure out how to get linting tools, formatting, sanitising, profiling, analysis, etc. working.
- Add the Google Test Library for Testing
- Try to make it compatible with Windows [^1]
- I'm no expert - I'm learning all this and experimenting with C++20 Modules myself
- I also got a book on CMake and am reading it to better understand how I should set up the Project
[^1] - Regarding Windows-compatibility: at this point [since I'm not yet using too many Linux-specific stuff, apart from clang++], it's just a matter of changing the CMake Presets to use the cl
or clang-cl
compiler chains.
I guess you could use the following Presets and run cmake --preset=default && cmake --build build
command from the VS Developer PowerShell, and everything should work, if you have Ninja, vcpkg and cmake available to the system.
{
"version": 6,
"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}