Embed with automatic download
FetchContent
is a CMake command that can automatically download the Matplot++ repository. Check if you have Cmake 3.14+ installed:
1 |
|
Include FetchContent in your CMake build script:
1 |
|
Declare the source for the contents:
1 2 3 |
|
Let CMake download the repository and include it as a subdirectory.
1 2 3 4 5 |
|
When creating your executable, link the library to the targets you want:
1 2 |
|
Then add this header to your source files:
1 |
|
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.