The preferred way to build JKQTPlotter is using <a href="https://cmake.org/">CMake</a>. You can find a detailed explanation of CMake at https://cliutils.gitlab.io/modern-cmake/. The CMake-build is defined in `CMakeLists.txt` files, found in many of the directories of the code repository. Especially in the root directory and the two subdirectories \code ./lib/ \endcode and \code ./examples/ \endcode .
You can build JKQTPlotter (and also the examples) by either opening the file <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/CMakeLists.txt">CMakeLists.txt</a> in QTCreator (which has CMake integration), or by calling \c CMake by hand. How to do this depends on your local system und build environment.
\subsubsection page_buildinstructions_CMAKE_MAKEFILE Building with MinGW/GNU/... Makefiles
Where \code <path_to_your_qt_sources> \endcode could be e.g. \code C:/development/Qt5/5.12.0/msvc2017_64 \endcode . This call results in a Visual Studio solution \c build/JKQTPlotter.sln that you can load and compile from the Visual Studio IDE. Alternatively you can also build the solution directly calling:
\subsection page_buildinstructions_CMAKE_CONFIG Configuring a Build with CMake
The CMake build system offers several configuration variables that you may set/change to modify the outcome of the build:
- \c CMAKE_PREFIX_PATH : add the path to your Qt installatrion to this variable, so the \c find_package(Qt5...) commands find the libraries you want to use
You can find an example project that uses a complete cmake-build here: \ref JKQTCMakeLinkExample (online: <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/examples/cmake_link_example">https://github.com/jkriege2/JKQtPlotter/blob/master/examples/cmake_link_example</a>).
Here is the \c CMakeLists.txt from that directory:
The you can use the generated makefiles (e.g. load them in an editor, or build them jsing \c make ). In the last line above, you need to specify two directories:
- \code <path_to_your_qt_sources> \endcode points to you Qt installation
- \code <path_to_lib/cmake_dir_of_JKQTPLOTTER> \endcode points to the directory containing the \c XYZ.cmake -files from the JKQTPlotter build. Typically this is \code <JKQTPLOTTER_INSTALL_DIR>/lib/cmake \endcode , where \code <JKQTPLOTTER_INSTALL_DIR> \endcode is the directory into which you installed JKQTPlotter.
If you want to simply include the JKQTPlotter Source code into your projects, without build a shared or static library and linking against it, you can use one of these QMake-Include files:
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/lib/jkqtplotter.pri">lib/jkqtplotter.pri</a> includes the complete library (JKQTPlotter, JKQTFastPlotter, JKQTMathText)
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/lib/jkqtmathtext.pri">lib/jkqtmathtext.pri</a> includes only JKQTMathText
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/lib/jkqtfastplotter.pri">lib/jkqtfastplotter.pri</a> includes only JKQTFastPlotter
.
In your QMake-projects it is then sufficient to add a line like:
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/staticlib/jkqtplotterlib/jkqtplotterlib.pro">qmake/staticlib/jkqtplotterlib/jkqtplotterlib.pro</a> builds the complete library (JKQTPlotter, JKQTFastPlotter, JKQTMathText) as static link library
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/staticlib/jkqtmathtextlib/jkqtmathtextlib.pro">qmake/staticlib/jkqtmathtextlib/jkqtmathtextlib.pro</a> builds only JKQTMathText as static link library
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/staticlib/jkqtfastplotterlib/jkqtfastplotterlib.pro">qmake/staticlib/jkqtfastplotterlib/jkqtfastplotterlib.pro</a> builds only JKQTFastPlotter as static link library
This snippet assumes that you built the libraries with the provided \code .PRO \endcode -files. You can also add a second \code .PRO \endcode -file to your projects, which integrates both as subdirs. Such files are used for all examples in this project. Here is an example:
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/sharedlib/jkqtplotterlib/jkqtplotterlib.pro">qmake/sharedlib/jkqtplotterlib/jkqtplotterlib.pro</a> builds the complete library (JKQTPlotter, JKQTFastPlotter, JKQTMathText) as shared library
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/sharedlib/jkqtmathtextlib/jkqtmathtextlib.pro">qmake/sharedlib/jkqtmathtextlib/jkqtmathtextlib.pro</a> builds only JKQTMathText as shared library
- <a href="https://github.com/jkriege2/JKQtPlotter/blob/master/qmake/sharedlib/jkqtfastplotterlib/jkqtfastplotterlib.pro">qmake/sharedlib/jkqtfastplotterlib/jkqtfastplotterlib.pro</a> builds only JKQTFastPlotter as shared library
This snippet assumes that you built the libraries with the provided `.PRO`-files. You can also add a second `.pro`-file to your projects, which integrates both as subdirs. Such files are used for all examples in this project. Here is an example:
# your project file, with declared dependencies on jkqtplotterlib_shared
test_styling.file=$$PWD/test_styling.pro
test_styling.depends = jkqtplotterlib_shared
# add the two entries to SUBDIRS
SUBDIRS += jkqtplotterlib_shared test_styling
\endcode
\note You will have to run a deployment step `make install` before running your executable, so the shared libararies are actually copied to the output directory (see `INSTALLS + ...` above).
\subsection page_buildinstructions_QMAKEQTCREATOR QMake in QTCreator
You can load the file \c JKQtPlotterBuildAllExamples.pro in te base directory of the project directly in QtCreator and use it to build the library and the examples.