Use C++ Modules and import std
Use C++ Modules and import std
macOS + Clang
Warning
Clang version must be at least 19.
- Install tools
| |
Note
- The AppleClang version is relatively old. To use the latest features, it is recommended to use the LLVM provided by Homebrew.
- The
import stdfeature requires Ninja.
- Configure the CMake command line
- Generator: It is recommended to use the latest Multi-Config generator so that Debug and Release configurations can be generated in the same folder.
| |
- System standard library (macOS-specific configuration)
| |
Note
- You can use
xcrun --sdk macosx --show-sdk-pathto view the exact path. - It is recommended to use the system-provided standard library rather than linking to the
libc++andlibunwindprovided by Homebrew LLVM.
- JSON file for the
stdmodule
| |
Note
You can locate the specific path using
find /opt/homebrew -name "libc++.modules.json" -maxdepth 10,
then rewrite it as /opt/homebrew/opt/llvm/....
- Configure
CMakeLists.txt
CMakeLists.txt
| |
Linux + gcc
Warning
gcc version must be at least 15.
Note
Operations not mentioned are exactly the same as on macOS.
- Install tools
| |
| |
- JSON file for the
stdmodule: obtain it with the following command
| |
- Modify
CMakeLists.txt
| |
Windows + MSVC
Warning
MSVC version must be at least 14.36 (equivalent to Visual Studio 2022 v17.6).
The steps are basically the same as macOS, but you do not need to provide CMAKE_CXX_STDLIB_MODULES_JSON.
Last updated on