-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (32 loc) · 1.04 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
38
39
40
41
42
43
44
45
TGT_TEST_DIR = test
TGT_TEST = $(TGT_TEST_DIR)/coder_test
SRCS_TEST = $(wildcard $(addsuffix *.cpp,$(TGT_TEST_DIR)/))
CATCH_VERSION = v3.3.2
CATCH_DIR = catch
CATCH_PATH = $(CATCH_DIR)/catch_amalgamated
CATCH_SRC = $(CATCH_PATH).cpp
CATCH_OBJ = $(CATCH_SRC:.cpp=.o)
CATCH_DL = $(addprefix $(CATCH_PATH),.cpp .hpp)
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++20
CXXFLAGS_TEST = -MMD -MP -ggdb
OBJS_TEST = $(SRCS_TEST:.cpp=.o)
DEPS_TEST = $(SRCS_TEST:.cpp=.d)
DBG_TEST = $(TGT_TEST).dSYM
RM = rm -rf
.PHONY: all test clean dist-clean
all: $(TGT_TEST) test
test: $(TGT_TEST)
@./$<
$(CATCH_DL):
mkdir -p catch
curl -sS -L -o $@ https://github.com/catchorg/Catch2/releases/download/$(CATCH_VERSION)/$(notdir $@)
$(CATCH_OBJ): $(CATCH_DL)
$(CXX) -c $< $(CXXFLAGS) -o $@
$(TGT_TEST): $(CATCH_OBJ) $(SRCS_TEST)
$(CXX) $(CXXFLAGS) $(CXXFLAGS_TEST) $^ -o $@
clean:
$(RM) $(CATCH_OBJ) $(TGT_TEST) $(DEPS) $(DEPS_TEST) $(DBG_TEST)
dist-clean: clean
$(RM) $(CATCH_DIR)
-include $(DEPS_TEST)