-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
28 lines (22 loc) · 1023 Bytes
/
Makefile
File metadata and controls
28 lines (22 loc) · 1023 Bytes
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
CXX := g++
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -pedantic
BIN := bin
# 查找所有源文件,跳过外部构建目录
SRC := $(shell find src examples -name "*.cpp" -not -path "*/build/*")
EXES := $(patsubst %.cpp,$(BIN)/%,$(SRC))
all: $(EXES)
$(BIN)/%: %.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm -rf $(BIN)
# 按主题编译
classes: $(filter $(BIN)/src/01_classes_and_objects/%,$(EXES))
this-pointer: $(filter $(BIN)/src/02_this_pointer/%,$(EXES))
constructors: $(filter $(BIN)/src/03_constructors_destructors/%,$(EXES))
inheritance: $(filter $(BIN)/src/04_oop_inheritance/%,$(EXES))
virtual-polymorphism: $(filter $(BIN)/src/05_cpp_virtual_polymorphism_demo/%,$(EXES))
operator-overloading: $(filter $(BIN)/src/06_operator_overloading_demos/%,$(EXES))
io-examples: $(filter $(BIN)/src/07_io_examples/%,$(EXES))
examples: $(filter $(BIN)/examples/%,$(EXES))
.PHONY: all clean classes this-pointer constructors inheritance virtual-polymorphism operator-overloading io-examples examples