According to this and CMake 3.28, we should be able to import std
without any extra effort.
But I'm getting the error Module 'std' not found with following simple demo.
import std;
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
cmake_minimum_required(VERSION 3.28)
project(module_tst)
set(CMAKE_CXX_STANDARD 23)
add_executable(demo)
target_sources(demo
PRIVATE
main.cpp
)
import std works well in Visual Studio, as long as I checked C/C++ -> General -> Scan Sources for Module Dependencies. I found something similar in cmake document that is CXX_SCAN_FOR_MODULES but set it on makes no difference. Is there anything missing?
I'm using latest cmake 3.28 rc1 and VS 17.8.0 Preview 4.0
After I did tried c++ module for few month. As far as I knew (for MSVC only).
import stdwas changed toimport std.corehere.c++ module for MSVCcomponent. It wasn't selected by default. You could install them by goto Visual Studio Installer > Modify./experimental:modulewhen complie command even document say "enabled automatically by either /std:c++20 or /std:c++latest" link.import std.coreyet.here my boilerplate.