-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·64 lines (52 loc) · 1.41 KB
/
Copy pathMakefile
File metadata and controls
executable file
·64 lines (52 loc) · 1.41 KB
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
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
PREFIX := $(MKFILE_DIR)/deps
NUM_PROCS := $(shell expr `nproc` / 2)
define cmake_build
cd build || return \
&& cmake \
-DCMAKE_BUILD_TYPE=$1 \
-DCMAKE_PREFIX_PATH=$(PREFIX) \
-DCMAKE_LIBRARY_PATH=$(PREFIX)\lib \
.. \
&& make -j$(NUM_PROCS)
endef
.PHONY: help
help:
@echo "\033[1;34m[make targets]:\033[0m"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[1;36m%-14s\033[0m%s\n", $$1, $$2}'
.PHONY: setup
setup:
@mkdir -p build
.PHONY: all
all: deps release ## Build all
.PHONY: deps
deps: setup ## Build dependencies
@echo "[Build Dependencies]"
@make -s -C deps all
.PHONY: release
release: setup ## Build in release mode
$(call cmake_build,Release)
.PHONY: relwithdeb
relwithdeb: setup ## Build in release mode with debug info
$(call cmake_build,RelWithDebInfo)
.PHONY: debug
debug: setup ## Build in debug mode
$(call cmake_build,Debug)
.PHONY: unittests
unittests: relwithdeb ## Build and run tests
@./build/unittests
.PHONY: format-code
format-code: ## Run clang-format
@find lib \
-type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) \
-exec clang-format -i {} +
.PHONY: clean
clean: ## Clean
@rm -rf build
#.PHONY: docs
#docs: ## Build docs
# ctags -R docs/source/notes --languages=reStructuredText
# make -s -C docs html