-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
45 lines (34 loc) · 1.09 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
# The Art of C++
# Copyright (c) 2018-2024 Dr. Colin Hirsch and Daniel Frey
# Please see LICENSE for license or visit https://github.com/taocpp/config
.SUFFIXES:
.SECONDARY:
CXXSTD = -std=c++17
CPPFLAGS ?= -pedantic -Iinclude -Iexternal/json/include -Iexternal/json/external/PEGTL/include
CXXFLAGS ?= -Wall -Wextra -Werror -O3
HEADERS := $(shell find include -name "*.hpp")
SOURCES := $(shell find src -name '*.cpp')
DEPENDS := $(SOURCES:src/%.cpp=build/dep/%.d)
BINARIES := $(SOURCES:src/%.cpp=build/bin/%)
UNIT_TESTS := $(filter build/bin/test/%,$(BINARIES))
.PHONY: all
all: compile check
.PHONY: compile
compile: $(BINARIES)
.PHONY: check
check: $(UNIT_TESTS)
echo $(UNIT_TESTS)
@set -e; for T in $(UNIT_TESTS); do echo $$T; TAO_CONFIG_VAR=hello $$T; done
.PHONE: clean
clean:
@rm -rf build/*
@find . -name '*~' -delete
build/dep/%.d: src/%.cpp Makefile
@mkdir -p $(@D)
$(CXX) $(CXXSTD) $(CPPFLAGS) -MM -MQ $@ $< -o $@
build/bin/%: src/%.cpp build/dep/%.d
@mkdir -p $(@D)
$(CXX) $(CXXSTD) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
ifeq ($(findstring $(MAKECMDGOALS),clean),)
-include $(DEPENDS)
endif