-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
77 lines (62 loc) · 1.89 KB
/
Copy pathmakefile
File metadata and controls
77 lines (62 loc) · 1.89 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
65
66
67
68
69
70
71
72
73
74
75
76
77
.ONESHELL:
.PHONY: setup setup-prod build build-prod run run-build-if clean rebuild production help
BUILD_DIR := build
BIN_DIR := $(BUILD_DIR)\bin
JOBS ?= 4
EXECUTABLE_TEST := CPP_CONSOLE
ifeq ($(OS),Windows_NT)
EXE := .exe
SEP := \\
CLEAN := cmd /c del /Q
EXEC_PREFIX :=
else
EXE :=
SEP := /
CLEAN := rm -rf
EXEC_PREFIX := ./
endif
# Run once when first initializing project
setup:
cmake -S . -B $(BUILD_DIR) -G Ninja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Debug
# Sets up program to be build for production
setup-prod:
cmake -S . -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release
# Runs the CMake file
build:
cmake --build $(BUILD_DIR) --config Debug -- -j$(JOBS)
# Runs the CMake file in production mode
build-prod:
cmake --build $(BUILD_DIR) --config Release -- -j$(JOBS)
run-test: build
@echo Running test executable...
cd $(BIN_DIR) && "${EXEC_PREFIX}$(EXECUTABLE_TEST)$(EXE)" $(args)
# Cleans up the build directory
clean:
$(CLEAN) $(BUILD_DIR)
rebuild: clean setup run-test
production: clean setup-prod build-prod
build-docs:
cmake --build $(BUILD_DIR) --target doxygen
help:
@echo "Available targets:"
@echo " setup - Configure Debug build"
@echo " setup-prod - Configure Release build"
@echo " build - Build Debug build"
@echo " build-prod - Build Release build"
@echo " run-test - Run Debug test executable"
@echo " clean - Remove build directory"
@echo " rebuild - Clean, setup Debug, build and run"
@echo " build-docs - Build documentation"
# >>> graft: clang-format >>>
.PHONY: graft-precommit-install setup-dev clang-format clang-format-check
graft-precommit-install:
pre-commit install
setup-dev: setup graft-precommit-install
clang-format:
cmake --build $(BUILD_DIR) --target clang-format
clang-format-check:
cmake --build $(BUILD_DIR) --target clang-format-check
# <<< graft: clang-format <<<