According to the official website, “QCustomPlot is a Qt widget for plotting and data visualization.” Repository gitlab.
The library has existed since 2013 and is good documented. Pleased with the availability examples. Has no dependencies other than Qt itself, which makes it easier
lifeporting to other platforms/cross-compilation. Current revision 2.1.1 supports qt 6.4.
During my institute days, I actively used to write all kinds of strength-of-material demos that we had as homework and, just as actively, I got my fellow students hooked on the subject. After the regular one, for that Delphi university with its windows forms, qcp seemed like mana from heaven.
Liba is good. The only BUT is that there is no integration into the cmake build system, or I couldn’t find ready-made ones. The archives from the official website contain qmake scripts, and github is filled with demos.
After sitting for an evening, I want to share my thoughts on how you can quickly connect this to your cmake project using standard means, without manually downloading the source code and using a couple of lines in the cmake script.
Cmake allows you to do some things during configuration: follow the url, go to the remote repo, unpack, build. This is what he does FetchContent. Textbook example suggests using a construction where we declare a resource:
Then we make it available:
This pair of commands will allow you to download and unpack the sources. Further
FetchContent will try to find the root CMakeLists.txt and, if present, execute
When should you not call FetchContent_MakeAvailable explicitly?
The mechanism is described on the same documentation page Integrating With find_package.
It makes the declared resource visible to
find_package. In other words, if
find_package(target) did not find target in CMAKE_PREFIX_PATH and others, it will turn to
QCustomPlot does not have a core cmake list. Accordingly, it will not be possible to import the library target. Let’s write a trivial
qcustomplot_SOURCE_DIR will determine MakeAvailable for us.
The order of the commands seems to me consistent with their appearance in the article. An example from the documentation about Complex Dependency Hierarchies where someFile.c is copied before an explicit call to add_subdirectory.
The repo is ready for you to use link.
Example use via standard