Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
266 lines (219 loc) · 7.08 KB
/
Copy pathMakefile
File metadata and controls
266 lines (219 loc) · 7.08 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
.PHONY: help
help:
@echo Build C++ with GCC/Clang/MSVC and CMake
@echo =======================================
@echo build-gcc/clang/msvc builds the project
@echo run-gcc/clang/msvc runs a and executable Default: exe=line
@echo clean-gcc/clang/msvc deletes all compiled files (preparation for re-compilation)
@echo rebuild-gcc/clang/msvc re-compiles the whole project
@echo ---
@echo Build the Documentation
@echo =======================
@echo build-docs builds the documentation with Doxygen/doxybook2/mkdocs
@echo serve-docs opens a browser to show the documentation and starts an html server
@echo deploy-docs deploys the website to the branch `gh-pages` and pushes it
#############################################################
# OS independend commands
#############################################################
# Detect the operating system
OS ?= $(shell uname -s)
# Remove a file
ifeq ($(OS),Windows_NT)
RM = del
else
RM = rm
endif
# Remove a directory
ifeq ($(OS),Windows_NT)
RMDIR = rmdir /S /Q
else
RMDIR = rm -rf
endif
# create a timestamp file
ifeq ($(OS),Windows_NT)
TIMESTAMP = type nul > $@
else
TIMESTAMP = touch $@
endif
# Define OPEN_BROWSER command based on the OS
ifeq ($(OS),Windows_NT)
OPEN_BROWSER = cmd /c start
else ifeq ($(OS),Linux)
OPEN_BROWSER = xdg-open
else ifeq ($(OS),Darwin)
OPEN_BROWSER = open
endif
# find files recursively
ifeq ($(OS),Windows_NT)
FIND_FILES = $(shell dir /s /b $(1))
else
FIND_FILES = $(shell find $(1) -type f)
endif
# export an environment variable
ifeq ($(OS),Windows_NT)
EXPORT = set
else
EXPORT = export
endif
#############################################################
# Build C++ with GCC and CMake
#############################################################
# build-gcc
# builds the project
#
# run-gcc
# runs a and executable Default: exe=line
#
# clean-gcc
# deletes all compiled files (preparation for re-compilation)
#
# rebuild-gcc
# re-compiles the whole project
# private: generate the build configuration for ninja
build_gcc/CMakeCache.txt: CMakeLists.txt
$(EXPORT) CC=gcc & $(EXPORT) CXX=g++ & cmake -S . -B build_gcc -G "Ninja Multi-Config" -DBUILD_EXAMPLES=ON
# private: compile the project
build_gcc\examples\Release\.timestamp: build_gcc/CMakeCache.txt plotpp/* examples/*
$(EXPORT) CC=gcc & $(EXPORT) CXX=g++ & cmake --build build_gcc --config Release
$(TIMESTAMP)
# public: build the project
.PHONY: build-gcc
build-gcc: cls build_gcc\examples\Release\.timestamp
# public: run one of the compiled executables
exe=line
.PHONY: run-gcc
run-gcc: build-gcc
.\build_gcc\examples\Release\$(exe).exe
# public: clean the build binary files
.PHONY: clean-gcc
clean-gcc:
cmake --build build_gcc --config Release --target clean
$(RM) build_gcc\examples\Release\.timestamp
# public: re-compile the project
.PHONY: rebuild-gcc
rebuild-gcc: clean-gcc build-gcc
#############################################################
# Build C++ with Clang and CMake
#############################################################
# build-clang
# builds the project
#
# run-clang
# runs a and executable Default: exe=line
#
# clean-clang
# deletes all compiled files (preparation for re-compilation)
#
# rebuild-clang
# re-compiles the whole project
# private: generate the build configuration for ninja
build_clang/CMakeCache.txt: CMakeLists.txt
$(EXPORT) CC=clang & $(EXPORT) CXX=clang++ & cmake -S . -B build_clang -G "Ninja Multi-Config" -DBUILD_EXAMPLES=ON
# private: compile the project
build_clang\examples\Release\.timestamp: build_clang/CMakeCache.txt plotpp/* examples/*
$(EXPORT) CC=clang & $(EXPORT) CXX=clang++ & cmake --build build_clang --config Release
$(TIMESTAMP)
# public: build the project
.PHONY: build-clang
build-clang: cls build_clang\examples\Release\.timestamp
# public: run one of the compiled executables
exe=line
.PHONY: run-clang
run-clang: build-clang
.\build_clang\examples\Release\$(exe).exe
# public: clean the build binary files
.PHONY: clean-clang
clean-clang:
cmake --build build_clang --config Release --target clean
$(RM) build_clang\examples\Release\.timestamp
# public: re-compile the project
.PHONY: rebuild-clang
rebuild-clang: clean-clang build-clang
#############################################################
# Build C++ with MSVC and CMake
#############################################################
# build-msvc
# builds the project
#
# run-msvc
# runs a and executable Default: exe=line
#
# clean-msvc
# deletes all compiled files (preparation for re-compilation)
#
# rebuild-msvc
# re-compiles the whole project
# private: generate the build configuration for ninja
build_msvc/CMakeCache.txt: CMakeLists.txt
cmake -S . -B build_msvc -G "Visual Studio 17 2022" -DBUILD_EXAMPLES=ON
# private: compile the project
build_msvc\examples\Release\.timestamp: build_msvc/CMakeCache.txt plotpp/* examples/*
cmake --build build_msvc --config Release
$(TIMESTAMP)
# public: build the project
.PHONY: build-msvc
build-msvc: cls build_msvc\examples\Release\.timestamp
# public: run one of the compiled executables
exe=line
.PHONY: run-msvc
run-msvc: build-msvc
.\build_msvc\examples\Release\$(exe).exe
# public: clean the build binary files
.PHONY: clean-msvc
clean-msvc:
cmake --build build_msvc --config Release --target clean
$(RM) build_msvc\examples\Release\.timestamp
# public: re-compile the project
.PHONY: rebuild-msvc
rebuild-msvc: clean-msvc build-msvc
#############################################################
# Documentation
#############################################################
# make commands
# -------------
# make build-docs
# builds the documentation with Doxygen/doxybook2/mkdocs
#
# make serve-docs
# opens a browser to show the documentation and starts an html server
#
# make deploy-docs
# deploys the website to the branch `gh-pages` and pushes it
# private: build doxygen xml from the source code
docs/doxygen/.timestamp: plotpp/* Doxyfile
doxygen Doxyfile
$(TIMESTAMP)
# private: convert doxygen xml to markdown
XML_INPUT = docs\doxygen\xml
MD_OUTPUT = docs\docs\API
docs/docs/API/.timestamp: docs/doxybook2-config.json docs/doxygen/.timestamp
if not exist $(MD_OUTPUT) mkdir $(MD_OUTPUT)
doxybook2 --input $(XML_INPUT) --output $(MD_OUTPUT) --config docs/doxybook2-config.json
$(TIMESTAMP)
# private: build the website with mkdocs from the markdown files
docs/site/.timestamp: docs/mkdocs.yml $(call FIND_FILES,"docs/docs") docs/docs/API/.timestamp
mkdocs build -f docs/mkdocs.yml
$(TIMESTAMP)
# public: build the documentation
.PHONY: build-docs
build-docs: docs/site/.timestamp
# public: show the documentation
.PHONY: serve-docs
serve-docs: build-docs
$(OPEN_BROWSER) http://127.0.0.1:8000/
mkdocs serve -f docs/mkdocs.yml
# public: deploy the documentation to github
.PHONY: deploy-docs
deploy-docs: build-docs
mkdocs gh-deploy -f docs/mkdocs.yml
.PHONY: clean-docs
clean-docs:
$(RMDIR) "docs/doxygen"
$(RMDIR) "docs/site"
$(RMDIR) "docs/docs/API"
#############################################################
# Misc
#############################################################
.PHONY: cls
cls:
cls