alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.24k stars 325 forks source link

Add Presets for Installation #262

Closed codeinred closed 2 years ago

codeinred commented 2 years ago

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.

If you have CMake 3.21 or greater, you can use the system build preset to build the package system-wide:

cmake --preset=system
cmake --build --preset=system
sudo cmake --install build/system

Alternatively, if the CMAKE_PREFIX_PATH environment variable is set to $HOME/.local, then you can install it locally. This can be set in /etc/profile or your shell config. This will not affect discovery of packages installed system-wide.

export CMAKE_PREFIX_PATH="$HOME/.local"

This has the advantage of not requiring sudo, and matplotplusplus will be installed in $HOME/.local.

cmake --preset=local
cmake --build --preset=local
cmake --install build/local

If you're using a version of CMake too old to support presets, then building with the system preset is equivilant to:

cmake -B build/system         \
    -DBUILD_EXAMPLES=OFF      \
    -DBUILD_SHARED_LIBS=ON    \
    -DBUILD_TESTS=OFF         \
    -CMAKE_BUILD_TYPE=Release \
    -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

cmake --build build/system

While building with the local preset is equivilant to:

cmake -B build/local                      \
    -DBUILD_EXAMPLES=OFF                  \
    -DBUILD_SHARED_LIBS=ON                \
    -DBUILD_TESTS=OFF                     \
    -DCMAKE_BUILD_TYPE=Release            \
    -DCMAKE_INSTALL_PREFIX="$HOME/.local" \
    -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

cmake --build build/local
alandefreitas commented 2 years ago

Well... that looks good. Thanks, @codeinred!