-
Notifications
You must be signed in to change notification settings - Fork 280
/
Makefile
96 lines (76 loc) · 2.74 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Make any tests, and possibly run them.
# A selection of variables are exported from the master Makefile.
# As each test will have a main function we need to handle this file by file.
# We're using the fairly typical convention that any file ending in _test.cpp
# is a test executable.
SOURCES = $(wildcard *.cpp)
OBJS = $(sort $(SOURCES:%.cpp=$(ODIR)/%.o))
TARGET_NAME = cataclysm-bn
CATA_LIB=../$(BUILD_PREFIX)$(TARGET_NAME).a
# If you invoke this makefile directly and the parent directory was
# built with BUILD_PREFIX set, you must set it for this invocation as well.
ODIR ?= obj
LDFLAGS += -lpthread -L.
# Enabling benchmarks
DEFINES += -DCATCH_CONFIG_ENABLE_BENCHMARKING
# Allow use of any header files from cataclysm.
# Catch sections throw unused variable warnings.
# Add no-sign-compare to fix MXE issue when compiling
# Catch also uses "#pragma gcc diagnostic", which is not recognized on some supported compilers.
# Clang and mingw are warning about Catch macros around perfectly normal boolean operations.
CXXFLAGS += -I../src -I../src/lua -Wno-unused-variable -Wno-sign-compare -Wno-unknown-pragmas -Wno-parentheses -MMD -MP
CXXFLAGS += -Wall -Wextra \
-Wno-range-loop-analysis # TODO: Fix warnings instead of disabling
ifndef PCH
PCH = 1
endif
ifndef CLANG
CLANG = 0
endif
ifeq ($(PCH), 1)
PCHFLAGS += -DCATA_CATCH_PCH
PCH_H = pch/tests-pch.hpp
ifeq ($(CLANG), 0)
PCH_P = $(PCH_H).gch
else
PCH_P = $(PCH_H).pch
CXXFLAGS += -Wno-unused-macros
endif
endif
ifeq ($(TARGETSYSTEM), WINDOWS)
TEST_TARGET = $(BUILD_PREFIX)cata_test.exe
else
TEST_TARGET = $(BUILD_PREFIX)cata_test
endif
tests: $(TEST_TARGET)
$(TEST_TARGET): $(OBJS) $(CATA_LIB)
ifeq ($(VERBOSE),1)
+$(CXX) $(W32FLAGS) -o $@ $(DEFINES) $(OBJS) $(CATA_LIB) $(CXXFLAGS) $(LDFLAGS)
else
@echo "Linking $@..."
@$(CXX) $(W32FLAGS) -o $@ $(DEFINES) $(OBJS) $(CATA_LIB) $(CXXFLAGS) $(LDFLAGS)
endif
$(PCH_P): $(PCH_H)
-$(CXX) $(CPPFLAGS) $(DEFINES) $(subst -Werror,,$(CXXFLAGS)) -Wno-non-virtual-dtor -Wno-unused-macros -I. -c $(PCH_H) -o $(PCH_P)
# Iterate over all the individual tests.
check: $(TEST_TARGET)
cd .. && tests/$(TEST_TARGET) -d yes --rng-seed time
clean:
rm -rf *obj *objwin
rm -f *cata_test
rm -f pch/*pch.hpp.gch
rm -f pch/*pch.hpp.pch
rm -f pch/*pch.hpp.d
#Unconditionally create object directory on invocation.
$(shell mkdir -p $(ODIR))
# Adding ../tests/ so that the directory appears in __FILE__ for log messages
$(ODIR)/%.o: %.cpp $(PCH_P)
ifeq ($(VERBOSE),1)
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(subst main-pch,tests-pch,$(PCHFLAGS)) -c ../tests/$< -o $@
else
@echo $(@F)
@$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(subst main-pch,tests-pch,$(PCHFLAGS)) -c ../tests/$< -o $@
endif
.PHONY: clean check tests precompile_header
.SECONDARY: $(OBJS)
-include ${OBJS:.o=.d}