You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds presets for common use cases, including local and
system installation. It also updates the README to explain the use of
these presets and how they can be used for installation.
Copy file name to clipboardExpand all lines: README.md
+65Lines changed: 65 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -210,6 +210,71 @@ Add this header to your source files:
210
210
211
211
However, in larger projects, it's always recommended to look for Matplot++ with `find_package` before including it as a subdirectory to avoid [ODR errors](https://en.wikipedia.org/wiki/One_Definition_Rule).
212
212
213
+
#### Install as a Package via CMake
214
+
215
+
If you have CMake 3.21 or greater, you can use the `system` build preset to
216
+
build the package system-wide:
217
+
218
+
```bash
219
+
cmake --preset=system
220
+
cmake --build --preset=system
221
+
sudo cmake --install build/system
222
+
```
223
+
224
+
Alternatively, if the `CMAKE_PREFIX_PATH` environment variable is set to
225
+
`$HOME/.local`, then you can install it locally. This can be set in `/etc/profile`
226
+
or your shell config. This will not affect discovery of packages installed
227
+
system-wide.
228
+
229
+
```bash
230
+
export CMAKE_PREFIX_PATH="$HOME/.local"
231
+
```
232
+
233
+
This has the advantage of not
234
+
requiring sudo, and matplotplusplus will be installed in `$HOME/.local`.
235
+
236
+
```bash
237
+
cmake --preset=local
238
+
cmake --build --preset=local
239
+
cmake --install build/local
240
+
```
241
+
242
+
You can now use it from CMake with `find_package`:
If you're using a version of CMake too old to support presets, then building with
251
+
the system preset is equivilant to:
252
+
253
+
```bash
254
+
cmake -B build/system \
255
+
-DBUILD_EXAMPLES=OFF \
256
+
-DBUILD_SHARED_LIBS=ON \
257
+
-DBUILD_TESTS=OFF \
258
+
-CMAKE_BUILD_TYPE=Release \
259
+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
260
+
261
+
cmake --build build/system
262
+
```
263
+
264
+
While building with the local preset is equivilant to:
265
+
266
+
```bash
267
+
cmake -B build/local \
268
+
-DBUILD_EXAMPLES=OFF \
269
+
-DBUILD_SHARED_LIBS=ON \
270
+
-DBUILD_TESTS=OFF \
271
+
-DCMAKE_BUILD_TYPE=Release \
272
+
-DCMAKE_INSTALL_PREFIX="$HOME/.local" \
273
+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
274
+
275
+
cmake --build build/local
276
+
```
277
+
213
278
#### Embed with automatic download
214
279
215
280
`FetchContent` is a CMake command that can automatically download the Matplot++ repository. Check if you have [Cmake](http://cmake.org) 3.14+ installed:
0 commit comments