Skip to content

Embed with CPM.cmake

CPM.cmake is a nice wrapper around the CMake FetchContent function.

Check if you have Cmake 3.14+ installed:

1
cmake --version

Install CPM.cmake and then use this command to add Matplot++ to your build script:

1
2
3
4
5
6
7
CPMAddPackage(
    NAME matplotplusplus
    GITHUB_REPOSITORY alandefreitas/matplotplusplus
    GIT_TAG origin/master # or whatever tag you want
)
# ...
target_link_libraries(my_target PUBLIC matplot)

Then add this header to your source files:

1
#include <matplot/matplot.h>

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.

You can use:

1
option(CPM_USE_LOCAL_PACKAGES "Try `find_package` before downloading dependencies" ON)

in your build script to let CPM.cmake do that for you.