File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -35,4 +35,23 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
35
35
BASE_DIRS ${modules}
36
36
FILES ${modules} /std.ixx
37
37
)
38
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
39
+ include (CheckCXXSymbolExists)
40
+ check_cxx_symbol_exists(_LIBCPP_VERSION version libcxx)
41
+ if (libcxx)
42
+ find_path (modules REQUIRED
43
+ NAMES
44
+ std.cppm
45
+ PATH_SUFFIXES
46
+ share/libc++/v1
47
+ PATHS
48
+ "${CMAKE_CXX_COMPILER} /../.."
49
+ NO_DEFAULT_PATH
50
+ )
51
+ target_sources (${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES
52
+ BASE_DIRS ${modules}
53
+ FILES ${modules} /std.cppm
54
+ )
55
+ target_compile_options (${PROJECT_NAME} PRIVATE -Wno-reserved-module-identifier)
56
+ endif ()
38
57
endif ()
Original file line number Diff line number Diff line change
1
+ CLANG_DIR_CMD = $(PREFIX)clang++ -print-resource-dir
2
+ STD_CPPM_LOC = /../../../share/libc++/v1/std.cppm
3
+
4
+ hello.exe: main.cpp std.o std.pcm
5
+ $(PREFIX)clang++ -stdlib=libc++ -std=c++23 -fprebuilt-module-path=. main.cpp std.o -o hello.exe
6
+
7
+ std.o std.pcm: std.cppm.o
8
+ $(PREFIX)clang++ -stdlib=libc++ -std=c++23 -fmodule-output=std.pcm -c @std.cppm.o -Wno-reserved-module-identifier
9
+
10
+ std.cppm.o:
11
+ -FOR /F "delims=" %%i IN ('$(CLANG_DIR_CMD)') DO @echo %%i$(STD_CPPM_LOC) >> std.cppm.o
12
+ -printf `$(CLANG_DIR_CMD)`$(STD_CPPM_LOC) >> std.cppm.o
13
+
14
+ clean:
15
+ -rm *.pcm *.o *.exe
16
+ -del *.pcm *.o *.exe
Original file line number Diff line number Diff line change
1
+ #include < version>
2
+
3
+ // https://github.com/llvm/llvm-project/issues/89579
4
+ #ifdef _LIBCPP_VERSION
5
+ #define __cpp_lib_modules 202207L
6
+ #endif
7
+
8
+ #ifdef __cpp_lib_modules
1
9
import std;
10
+ #endif
2
11
3
12
int main ()
4
13
{
14
+ #ifdef __cpp_lib_modules
5
15
std::println (" {}" , " Hello, World!" );
16
+ #endif
6
17
}
You can’t perform that action at this time.
0 commit comments