-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (29 loc) · 1.03 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
TARGET = grzed
TESTTARGET = test
LDLIBS = -lncurses
CXX = g++
CXXFLAGS = -g -std=c++17 -Werror -Wall -Wextra -Wshadow -Wno-sign-compare -pedantic -fsanitize=address -fsanitize=undefined
RM = rm -f
FORMAT = clang-format -i
.PHONY: clean distclean format test
TARGETS = $(TARGET) $(TESTTARGET)
HEADERS = $(wildcard src/*.hpp)
OBJECTS = $(patsubst %.cpp, %.o, $(wildcard src/*.cpp))
MAINS = src/main.o src/main.cpp
TESTHEADERS = $(wildcard tests/*.hpp) $(HEADERS)
ALLOBJECTS = $(OBJECTS) $(patsubst %.cpp, %.o, $(wildcard tests/*.cpp))
TESTOBJECTS = $(filter-out $(MAINS),$(ALLOBJECTS))
SOURCEFILES = $(wildcard src/*.cpp tests/*.cpp) $(HEADERS) $(TESTHEADERS)
all: $(TARGET)
%.o: %.cpp $(HEADERS)
$(CXX) -I src -c $< -o $@ $(CXXFLAGS)
$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDLIBS) -o $@ $(CXXFLAGS)
$(TESTTARGET): $(TESTOBJECTS)
$(CXX) -I src $(TESTOBJECTS) $(LDLIBS) -lgtest_main -lgtest -o $@ $(CXXFLAGS)
format:
$(FORMAT) $(SOURCEFILES)
clean:
$(RM) $(wildcard src/*.o) $(wildcard tests/*.o)
distclean: clean
$(RM) $(TARGETS)