To use clang’s experimental library one has to add -fexperimental-library
compiler flag but that brokes otherwise perfectly working import std;
and vice versa.
Here goes MRE:
# CMakeLists.txt
cmake_minimum_required(VERSION 4.0.2)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
set(CMAKE_CXX_MODULE_STD 1)
project(main)
add_executable(main main.cxx)
target_compile_features(main PRIVATE cxx_std_23)
target_compile_options(main PRIVATE "-fexperimental-library")
// main.cxx
import std;
int main() {}
// Errors output when building with Ninja and Clang 20.1.5
[build] error: enable unstable and experimental library features was disabled in AST file 'CMakeFiles/__cmake_cxx23.dir/std.pcm' but is currently enabled
[build] error: module file CMakeFiles/__cmake_cxx23.dir/std.pcm cannot be loaded due to a configuration mismatch with the current compilation
How can I resolve this mismatch? Is there a way to manually edit those configurations?