Last active
April 17, 2026 09:27
-
-
Save MikuroXina/23a6d1c7812ebc4c3fd95babba24923d to your computer and use it in GitHub Desktop.
C++20 modules setup with CMake. Built with `mkdir build && cd build && CC=gcc-15 CXX=g++-15 cmake -GNinja .. && ninja -j8` in macOS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 4.3.1) | |
| cmake_policy(SET CMP0076 NEW) | |
| project(experiment) | |
| add_definitions(-Wall -g) | |
| add_library(list STATIC) | |
| target_compile_features(list PUBLIC cxx_std_20) | |
| target_sources(list PUBLIC | |
| FILE_SET CXX_MODULES | |
| FILES | |
| src/foo.cpp <-- Edit here to specify all c++ sources using modules | |
| ) | |
| add_executable(main src/main.cpp) | |
| target_compile_features(main PRIVATE cxx_std_20) | |
| target_link_libraries(main PRIVATE list) | |
| Include(FetchContent) | |
| FetchContent_Declare( | |
| Catch2 | |
| GIT_REPOSITORY https://github.com/catchorg/Catch2.git | |
| GIT_TAG v3.14.0 | |
| ) | |
| FetchContent_MakeAvailable(Catch2) | |
| add_executable(test src/test.cpp) | |
| target_link_libraries(test PRIVATE Catch2::Catch2WithMain list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment