-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
81 lines (68 loc) · 2.58 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -----------------------------------------------------------------------------
# CMake project wrapper Makefile ----------------------------------------------
# -----------------------------------------------------------------------------
SHELL := /bin/bash
RM := rm -rf
MKDIR := mkdir -p
BUILDROOT := Build
BUILDDEFAULT := Release
BUILDDIR = $(BUILDROOT)/$(BUILDDEFAULT)/
ROOTDIR := $(CURDIR)
BUILDTYPES := Release Debug MinSizeRel Coverage RelWithDebInfo Quick
OTHERGOALS := $(filter-out distclean $(BUILDTYPES),$(MAKECMDGOALS))
# Call make from build directory
.PHONY: all
all: ./$(BUILDROOT)/Release/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: Release
Release: BUILDDIR = $(BUILDROOT)/Release/
Release: ./$(BUILDROOT)/Release/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: MinSizeRel
MinSizeRel: BUILDDIR = $(BUILDROOT)/MinSizeRel/
MinSizeRel: ./$(BUILDROOT)/MinSizeRel/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: RelWithDebInfo
RelWithDebInfo: BUILDDIR = $(BUILDROOT)/RelWithDebInfo/
RelWithDebInfo: ./$(BUILDROOT)/RelWithDebInfo/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: Debug
Debug: BUILDDIR = $(BUILDROOT)/Debug/
Debug: ./$(BUILDROOT)/Debug/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: Coverage
Coverage: BUILDDIR = $(BUILDROOT)/Coverage/
Coverage: ./$(BUILDROOT)/Coverage/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Call make from build directory
.PHONY: Quick
Quick: BUILDDIR = $(BUILDROOT)/Quick/
Quick: ./$(BUILDROOT)/Quick/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
# Make build directory and call cmake
./$(BUILDROOT)/%/Makefile:
@ ($(MKDIR) $(BUILDROOT)/$* > /dev/null)
@ (cd $(BUILDROOT)/$* > /dev/null 2>&1 && cmake -DCMAKE_BUILD_TYPE=$* $(ROOTDIR))
# remove everything
distclean:
@ ($(MKDIR) $(BUILDDIR) > /dev/null)
@ (cd $(BUILDDIR) > /dev/null 2>&1 && cmake $(ROOTDIR) > /dev/null 2>&1)
@- $(MAKE) --silent -C $(BUILDDIR) clean || true
@- $(RM) ./$(BUILDDIR)/Makefile
@- $(RM) ./$(BUILDDIR)/CMake*
@- $(RM) ./$(BUILDDIR)/cmake.*
@- $(RM) ./$(BUILDDIR)/*.cmake
@- $(RM) ./$(BUILDDIR)/*.txt
# for all other goals pass them down to make in the build directory
ifeq ($(filter distclean $(BUILDTYPES),$(MAKECMDGOALS)),)
$(OTHERGOALS): ./$(BUILDDIR)/Makefile
@ $(MAKE) -s -C $(BUILDDIR) $(MAKEFLAGS) $(OTHERGOALS)
else
$(OTHERGOALS):
@true
endif