-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (43 loc) · 1.3 KB
/
Makefile
File metadata and controls
57 lines (43 loc) · 1.3 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
# MultistageOptimizer Makefile (wraps CMake)
#
# Usage examples:
# make build
# make test
# make clean
#
# Override variables:
# make BUILD_DIR=build CONFIG=Release
# make configure GENERATOR="Ninja"
# make configure GENERATOR="Visual Studio 17 2022" ARCH=x64
CMAKE ?= cmake
CTEST ?= ctest
BUILD_DIR ?= build
CONFIG ?= Release
# Optional: set CMake generator and platform/arch (mainly for Windows VS generators).
GENERATOR ?=
ARCH ?=
# For single-config generators (Ninja/Unix Makefiles). Multi-config generators ignore this.
CMAKE_BUILD_TYPE ?= $(CONFIG)
CMAKE_GEN_ARGS :=
ifneq ($(strip $(GENERATOR)),)
CMAKE_GEN_ARGS += -G "$(GENERATOR)"
endif
ifneq ($(strip $(ARCH)),)
CMAKE_GEN_ARGS += -A $(ARCH)
endif
.PHONY: all configure build test clean distclean help
all: build
configure:
$(CMAKE) -S . -B $(BUILD_DIR) $(CMAKE_GEN_ARGS) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
build: configure
$(CMAKE) --build $(BUILD_DIR) --config $(CONFIG)
test: build
$(CTEST) --test-dir $(BUILD_DIR) -C $(CONFIG) --output-on-failure
clean:
-$(CMAKE) --build $(BUILD_DIR) --target clean --config $(CONFIG)
distclean:
$(CMAKE) -E rm -rf $(BUILD_DIR)
help:
@echo "Targets: build, test, clean, distclean"
@echo "Vars: BUILD_DIR (default: build), CONFIG (default: Release)"
@echo "Optional vars: GENERATOR, ARCH"