So we will copy the module interface file to our binary tree for building.Īs usual, having the same primary module interface appear more than once in a program is not allowed. "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/2/modules/std.ixx"ĬMake rightfully prevents you from including module sources outside of your source tree in the build. # you don't want to hardcode the path here in a real-world project, Since CMake does not support importing pre-compiled modules at the moment, the easiest way to get things running is therefore to simply include the primary module interface for the standard library in your project.īe sure to first read this answer to understand the current prerequisites and limitations of the C 20 modules in CMake. So no special handling is required anymore.ĬMake is currently considering to provide an option for controlling this property.įor older versions of Visual Studio, you will have to compile the std named module yourself before importing it. Visual Studio 17.6 now also provides a property C/C ->Language->Build ISO C 23 Standard Library Modules which by default is set to Yes and will automatically build the standard library modules on /std:c latest as part of your project build. This will set the VS configuration property C/C ->Language->C Language Standard to /std:c latest. Simply set CMAKE_CXX_STANDARD to use C 23: With Visual Studio version 17.6.0 this became very straightforward. ifc is not a source file,how to deal with it in CMake? I can use copy %VCToolsInstallDir\modules\std.ixx to project folder and change std.ifc to std.ixx, but is there a more elegant way to achieve it to avoid building std module every time? I think it's because. main.cpp(5,5): error C2065: "cout" : Undeclared identifier Set_property(DIRECTORY $)įILE_SET all_my_modules TYPE CXX_MODULES FILESĪnd MSVC shows: main.cpp(1,11): error C2230: Could not find module "std" And these files can't work.(The std.ifc file is obtained from microsoft blog tutorial: cl /std:c latest /EHsc /nologo /W4 /MTd /c "%VCToolsInstallDir%\modules\std.ixx"(use in msvc 圆4 native console))ĬMakeList.txt CMAKE_MINIMUM_REQUIRED(VERSION 3.26) Until May 2023, MSVC support it but we need add Standard Library Modules manually as Microsoft blog mentioned.īut how to use import std in CMake project? The MS blog doesn't mentioned it. As we know, C 23 support Standard Library Modules.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |