Skip to content

Commit 726d081

Browse files
Update README.md
1 parent fb3029d commit 726d081

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,8 @@ Get the binary package from the [release section](https://github.com/alandefreit
20602060

20612061
If you need a more recent version of Matplot++, you can download the [binary packages from the CI artifacts](https://github.com/alandefreitas/matplotplusplus/actions?query=workflow%3AMatplotplusplus+event%3Apush) or build the library [from the source files](#build-from-source).
20622062

2063+
### Finding the Library
2064+
20632065
Once the package is installed, you can link your C++ program to the library and include the directories where you installed Matplot++. Unless you changed the default options, the library is likely to be in `/usr/local/` (Linux / Mac OS) or `C:/Program Files/` (Windows). The installer will try to find the directory where you usually keep your libraries but that's not always perfect.
20642066

20652067
If you are using CMake, you can then find Matplot++ with the usual `find_package` command:
@@ -2070,16 +2072,14 @@ find_package(Matplot++ REQUIRED)
20702072
target_link_libraries(my_target PUBLIC Matplot++::matplot)
20712073
```
20722074

2073-
You can see a complete example in [`test/integration/CMakeLists.txt`](test/integration/CMakeLists.txt).
2075+
You can see a complete example in [`test/integration/CMakeLists.txt`](test/integration/CMakeLists.txt). CMake should be able to locate the `matplot++-config.cmake` script automatically if you installed the library under `/usr/local/` (Linux / Mac OS).
20742076

2075-
CMake should be able to locate the `matplot++-config.cmake` script automatically if you installed the library under `/usr/local/` (Linux / Mac OS) or `C:/Program Files/` (Windows). Otherwise, if the library is under another directory, like `C:/Program Files (x86)` or `C:/Program Files (x86)/`, you need to include your installation directory in `CMAKE_MODULE_PATH` first:
2077+
Unfortunately, CMake does not have a single default directory for packages on Windows like `/usr/local/lib`. If CMake cannot find Matplot++ on Windows or if you installed the library outside the default directory on Linux/Mac OS, there are a few [options](https://stackoverflow.com/questions/21314893/what-is-the-default-search-path-for-find-package-in-windows-using-cmake):
20762078

2077-
```cmake
2078-
list(APPEND CMAKE_MODULE_PATH put/your/installation/directory/here)
2079-
find_package(Matplot++ REQUIRED)
2080-
# ...
2081-
target_link_libraries(my_target PUBLIC Matplot++::matplot)
2082-
```
2079+
* **Environment Variables**: The most reliable way to set this default directory is through environment variables. You can create an environment variable `MATPLOTPP_DIR` and then add `$ENV{MATPLOTPP_DIR}` to the `HINTS` section of the `find_package` command. This tends to be more convenient than requiring the path on the command line every time. Starting with version 3.12, CMake now implicitly considers the `<PackageName>_Root` environment variable a HINT for every `find_package` call.
2080+
* **Package Registry**: CMake offers the [Package Registry](https://cmake.org/cmake/help/v3.5/manual/cmake-packages.7.html#package-registry) as an alternative mechanism for finding package locations. CMake maintains a list of package information in the Windows registry under `HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\`.
2081+
* **Append CMAKE_MODULE_PATH**: You can append more directories to [`CMAKE_MODULE_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html) with something like `list(APPEND CMAKE_MODULE_PATH "C:\\Program Files\\matplotplusplus 1.0.1")`. `CMAKE_MODULE_PATH` is a list of search paths for CMake modules to be loaded by the `include()` or `find_package()` commands.
2082+
* **Set the DIR variable directly**: Directly set the `Matplot++_DIR` variable with something like `set(Matplot++_DIR "C:\\Program Files\\matplotplusplus 1.0.1\\lib\\cmake\\Matplot++")`. This might be good enough for small local projects but it is hard-coding the directory in your build script. When your library gets out of your local environment, you need to choose one of the other options above (better) or make this variable an option and require the user to provide the directory on the command line every time (worse).
20832083

20842084
### Package managers
20852085

0 commit comments

Comments
 (0)