-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
microsoft/STL#3108 https://learn.microsoft.com/en-us/cpp/cpp/tutorial-import-stl-named-module#import-the-standard-library-with-std
- Loading branch information
1 parent
1909990
commit 49640bb
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.27) | ||
project(import-std) | ||
|
||
set(CMAKE_CXX_STANDARD 23) | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) | ||
|
||
if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
# https://gitlab.kitware.com/cmake/cmake/-/issues/24922 | ||
file(CONFIGURE OUTPUT Directory.Build.props CONTENT [[ | ||
<Project> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<BuildStlModules>true</BuildStlModules> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
</Project> | ||
]] @ONLY) | ||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
cmake_path(CONVERT $ENV{VCTOOLSINSTALLDIR}/modules TO_CMAKE_PATH_LIST modules NORMALIZE) | ||
target_sources(${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES | ||
BASE_DIRS ${modules} | ||
FILES ${modules}/std.ixx | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
hello.exe: main.cpp | ||
cl /nologo /EHsc /std:c++latest "$(VCTOOLSINSTALLDIR)/modules/std.ixx" main.cpp /Fe:hello | ||
|
||
clean: | ||
-del *.ifc *.obj *.exe | ||
-rm *.ifc *.obj *.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import std; | ||
|
||
int main() | ||
{ | ||
std::println("{}", "Hello, World!"); | ||
} |