matplotplusplus icon indicating copy to clipboard operation
matplotplusplus copied to clipboard

Embed with CPM.cmake docs —CPM now has a CPMFindPackage() command

Open saxbophone opened this issue 3 years ago • 2 comments

Feature category

  • [ ] enhancement - build system
  • [ ] enhancement - backends
  • [ ] enhancement - build system
  • [x] enhancement - documentation
  • [ ] enhancement - plot categories

From the docs on embedding matplotplusplus using CPM.cmake:

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:

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

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

CPM now has an alternative command to CPMAddPackage(), one which looks for a locally installed copy of the library first, falling back to downloading and building it in-tree if it can't be found. It's called CPMFindPackage() and IIRC its arguments are identical to AddPackage's. The workaround mentioned in the docs is obsolete if FindPackage is available.

If you want to hold off on making this change in the docs until there's verified proof that it works fine, I'm planning to start trying out matplotplusplus soon myself. I've been using CPMFindPackage for over a year myself in my C++ projects no problem, I'm not expecting it to have any issues. I can let you know if it works fine?

saxbophone avatar Oct 29 '22 00:10 saxbophone

Hi @saxbophone

Thank you for the suggestion.

Yes. Sure.

Go ahead. Any tests, suggestions, and PRs are welcome.

alandefreitas avatar Oct 29 '22 08:10 alandefreitas

Hi @saxbophone, Just FYI, CMake 3.24.0 adds a similar functionality to the FetchContent module, see:

globberwops avatar Dec 23 '22 08:12 globberwops