-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (36 loc) · 1.62 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
# NOTE(dkorolev): 99% of the goal of this `Makefile` is to have `vim` jump to errors on `:mak`.
#
# NOTE(dkorolev): Yes, I am well aware it is ugly to have a `Makefile` for a `cmake`-built project.
# Just too much of a `vi` user to not leverage `:mak`.
# This `Makefile` also proves to be useful with Docker builds.
.PHONY: debug release debug_dir release_dir mark_deps_as_built indent clean
DEBUG_BUILD_DIR=$(shell echo "$${DEBUG_BUILD_DIR:-Debug}")
RELEASE_BUILD_DIR=$(shell echo "$${RELEASE_BUILD_DIR:-Release}")
OS=$(shell uname)
ifeq ($(OS),Darwin)
CORES=$(shell sysctl -n hw.physicalcpu)
else
CORES=$(shell nproc)
endif
CLANG_FORMAT=$(shell echo "$${CLANG_FORMAT:-clang-format-10}")
debug: debug_dir
MAKEFLAGS=--no-print-directory cmake --build "${DEBUG_BUILD_DIR}" -j ${CORES}
debug_dir: ${DEBUG_BUILD_DIR}
${DEBUG_BUILD_DIR}: CMakeLists.txt
cmake -B "${DEBUG_BUILD_DIR}" .
test: debug
(cd "${DEBUG_BUILD_DIR}"; make test)
release: release_dir
MAKEFLAGS=--no-print-directory cmake --build "${RELEASE_BUILD_DIR}" -j ${CORES}
release_dir: ${RELEASE_BUILD_DIR}
${RELEASE_BUILD_DIR}: CMakeLists.txt
cmake -DCMAKE_BUILD_TYPE=Release -B "${RELEASE_BUILD_DIR}" .
test_release: release
(cd "${RELEASE_BUILD_DIR}"; make test)
mark_deps_as_built:
[ -d ${DEBUG_BUILD_DIR}/_deps ] && (find ${DEBUG_BUILD_DIR}/_deps -type f | xargs touch -r CMakeLists.txt) || true
[ -d ${RELEASE_BUILD_DIR}/_deps ] && (find ${RELEASE_BUILD_DIR}/_deps -type f | xargs touch -r CMakeLists.txt) || true
indent:
${CLANG_FORMAT} -i $(shell find src/ -iname "*.cc")
clean:
rm -rf "${DEBUG_BUILD_DIR}" "${RELEASE_BUILD_DIR}"