C++ modules: 'import std;' with libc++ does not work
I'm using CMake 3.29.2040507 and a clang/libc++ 19.0 build
# CMakeLists.txt
cmake_minimum_required(VERSION 3.29.20240507-gf2b76d7)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
set(CMAKE_CXX_MODULE_STD ON)
project(example LANGUAGES CXX)
add_executable(main main.cpp)
# main.cpp
import std;
int main() { std::println("hi"); }
Running CMake like this on these files:
$ cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_CXX_FLAGS=-stdlib=libc++
produces the following error:
CMake Error in CMakeLists.txt:
The "CXX_MODULE_STD" property on the target "main" requires that the
"__CMAKE::CXX23" target exist, but it was not provided by the toolchain.