forked from nlohmann/json
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (48 loc) · 1.66 KB
/
Copy pathMakefile
File metadata and controls
62 lines (48 loc) · 1.66 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
.PHONY: clean
.PHONY: debug
.PHONY: default
.PHONY: release
.PHONY: .build
.PHONY: .configure
# ----- Environment ----------------------------------------------------------------
NPROC = $(shell grep -c processor /proc/cpuinfo)
OUTPUT_DIR ?= $(CURDIR)/_build
CMAKE_DIR = $(OUTPUT_DIR)/cmake
ifneq ($(shell hash ninja 2>&1),)
$(error ERROR: Ninja build system not found. Please install ninja. apt-get install ninja-build)
endif
# ----- Params ----------------------------------------------------------------
app ?= all
args ?=
CMAKE_SIZE ?= size
# -----------------------------------------------------------------------------
NLOHMANN_JSON_BUILD_DEMOS ?= ON
# ----- Flags -----------------------------------------------------------------
ifeq ($(VERBOSE), 1)
cmakeflags += -DCMAKE_VERBOSE_MAKEFILE=TRUE
else
MAKEFLAGS += --silent
endif
CMAKEFLAGS ?=
cmakecommonflags += ${CMAKEFLAGS}
cmakecommonflags += -GNinja
cmakecommonflags += $(if $(value CMAKE_BUILD_TYPE),-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE))
cmakeoptions += -DNLOHMANN_JSON_BUILD_DEMOS=$(NLOHMANN_JSON_BUILD_DEMOS)
cmakeflags += ${cmakecommonflags}
cmakeflags += -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$(OUTPUT_DIR) -DCMAKE_SIZE=$(CMAKE_SIZE)
cmakeflags += ${cmakeoptions}
cmakebuild += nice cmake --build
cmakebuildflags += --parallel $(NPROC)
# ----- Targets ---------------------------------------------------------------
default: debug
release: CMAKE_BUILD_TYPE = Release
release: .build
debug: CMAKE_BUILD_TYPE = Debug
debug: .build
clean:
rm -rf $(OUTPUT_DIR)
.build: | .configure .build_${app}
.configure:
cmake -S $(CURDIR) -B $(CMAKE_DIR) $(cmakeflags)
.build_%:
${cmakebuild} $(CMAKE_DIR) --target $* ${cmakebuildflags}