-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (27 loc) · 1.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.PHONY: all clean
# Needs Clang 15 or greater
CXX:= clang++
# Turn on C++20 mode which includes modules
CXXFLAGS:=-std=c++20
# Specify where prebuilt modules are placed. This is similar to '-I' for include
# files.
CPPFLAGS:=-fprebuilt-module-path=.
all: main
clean:
$(RM) main *.o *.pcm
# Modules (.cppm) generate a .pcm
%.pcm : %.cppm
$(CXX) $(CPPFLAGS) $(CXXFLAGS) --precompile $^ -o $@
# Precompiled modules (.pcm) generate a .o. Note lack of CPPFLAGS.
%.o : %.pcm
$(CXX) $(CXXFLAGS) -c $^ -o $@
# Same as the above two rules, but done in one call to the compiler. This won't have
# as much parallelism as the above.
# %.pcm %.o &: %.cppm
# $(CXX) $(CPPFLAGS) $(CXXFLAGS) -fmodule-output=$(addsuffix .pcm,$(basename $^)) -c $^ -o $(addsuffix .o,$(basename $^))
# It's important to specify that building main.o depends on the *compiled*
# module file. That allows the build system to build in the correct order.
main.o: main.cpp test.pcm
# This is standard
main: main.o test.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@