-
Notifications
You must be signed in to change notification settings - Fork 3
/
targets.mk
76 lines (57 loc) · 2.07 KB
/
targets.mk
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
INSTALL_PREFIX?=/home/sdowney/install
PROJECT?=$(shell basename $(CURDIR))
BUILD_DIR?=../cmake.bld/${PROJECT}
CONFIGURATION_TYPES?=RelWithDebInfo;Debug;Tsan;Asan;Msan
DEST?=../install
CMAKE_FLAGS?=
CONFIG?=RelWithDebInfo
USE_DOCKER_FILE>=.use-docker
export
ifeq ($(strip $(TOOLCHAIN)),)
_build_name?=build
_build_dir?=../cmake.bld/${PROJECT}
_configuration_types?="RelWithDebInfo;Debug;Tsan;Asan;Msan"
_cmake_args=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/etc/toolchain.cmake
else
_build_name?=build-$(TOOLCHAIN)
_build_dir?=../cmake.bld/${PROJECT}
_configuration_types?="RelWithDebInfo;Debug;Tsan;Asan;Msan"
_cmake_args=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/etc/$(TOOLCHAIN)-toolchain.cmake
endif
_build_path?=$(_build_dir)/$(_build_name)
define run_cmake =
cmake \
-G "Ninja Multi-Config" \
-DCMAKE_CONFIGURATION_TYPES=$(_configuration_types) \
-DCMAKE_INSTALL_PREFIX=$(abspath $(INSTALL_PREFIX)) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
$(_cmake_args) \
$(CURDIR)
endef
default: compile
$(_build_path):
mkdir -p $(_build_path)
$(_build_path)/CMakeCache.txt: | $(_build_path) .gitmodules
cd $(_build_path) && $(run_cmake)
-rm compile_commands.json
ln -s $(_build_path)/compile_commands.json
compile: $(_build_path)/CMakeCache.txt ## Compile the project
cmake --build $(_build_path) --config $(CONFIG) --target all -- -k 0
install: $(_build_path)/CMakeCache.txt ## Install the project
DESTDIR=$(abspath $(DEST)) ninja -C $(_build_path) -k 0 install
ctest: $(_build_path)/CMakeCache.txt ## Run CTest on current build
cd $(_build_path) && ctest --output-on-failure
ctest_ : compile
cd $(_build_path) && ctest --output-on-failure
test: ctest_ ## Rebuild and run tests
cmake: | $(_build_path)
cd $(_build_path) && ${run_cmake}
clean: $(_build_path)/CMakeCache.txt ## Clean the build artifacts
cmake --build $(_build_path) --config $(CONFIG) --target clean
realclean: ## Delete the build directory
rm -rf $(_build_path)
env:
$(foreach v, $(.VARIABLES), $(info $(v) = $($(v))))
view-maybe.pdf:
make -C papers view-maybe.pdf
.PHONY : compile install ctest ctest_ test cmake clean realclean env