-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
65 lines (50 loc) · 1.31 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
BASE_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_TYPE=debug
BUILD_INFO=Debug
ifdef RELEASE_DBG_INFO
BUILD_TYPE=release_dbg_info
BUILD_INFO=RelWithDebInfo
export RELEASE_DBG_INFO=1
endif
ifdef RELEASE
BUILD_TYPE=release
BUILD_INFO=Release
export RELEASE=1
endif
ifdef PREFIX
CMAKE_PREFIX="-DCMAKE_INSTALL_PREFIX=$(shell readlink -f $(PREFIX))"
endif
.PHONY: all build distclean clean release release_dbg_info debug install verifybuildtype
.SILENT:
all: release
build: build/Makefile
$(MAKE) -C build/
build/Makefile: src/CMakeLists.txt
@mkdir -p "build"
@cd "build" && \
cmake \
-DCMAKE_BUILD_TYPE=$(BUILD_INFO) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
"$(BASE_DIR)"/src \
$(CMAKE_PREFIX)
verifybuildtype: build/Makefile
if ! grep -q "^CMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)$$" build/CMakeCache.txt > /dev/null; \
then cd build;cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(BASE_DIR)/src; \
fi
debug:
$(MAKE) verifybuildtype DEBUG=1
$(MAKE) build DEBUG=1
release:
$(MAKE) verifybuildtype RELEASE=1
$(MAKE) build RELEASE=1
release_dbg_info:
$(MAKE) verifybuildtype RELEASE_DBG_INFO=1
$(MAKE) build RELEASE_DBG_INFO=1
install: build
$(MAKE) -C build install
uninstall: build/install_manifest.txt
$(MAKE) -C build uninstall
clean:
$(MAKE) -C "build" clean
distclean:
@rm -rf build