I attempted to upgrade to 4.0.2 but found that my modules projects using import std
are now unbuildable. I’m using Visual Studio Community 17.15.0 Preview 4.0 + Ninja.
After fiddling across a large-scale project with a number of C++ module deps, I went ahead and tried a minimal project to confirm, and it too was unbuildable. The CMakeLists for the minimal project looks like this:
cmake_minimum_required(VERSION 4.0.2)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_MODULE_STD 1)
project(minimal LANGUAGES CXX)
add_executable(minimal)
target_sources(minimal
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES FILES
main.ixx
)
I fiddled with various configurations (one call before another - i.e. sets
before project(...)
and after it, - different hashes for CMAKE_EXPERIMENTAL_CXX_IMPORT_STD, etc.). Regardless, the result is always this error:
CMake Error in CMakeLists.txt:
The "CXX_MODULE_STD" property on the target "minimal" requires that the
"__CMAKE::CXX23" target exist, but it was not provided by the toolchain.
Reason:
Experimental `import std` support not enabled when detecting toolchain; it must be set before `CXX` is enabled (usually a `project()` call)
Rolling back to 3.31.7 is the only way I could get things to build again.