mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
34b31812ba
+ CMAKE now properly adds the Build-type when building libraries + removed some more compiler warning
180 lines
9.2 KiB
Plaintext
180 lines
9.2 KiB
Plaintext
/*!
|
|
|
|
\page page_buildinstructions Build Instructions
|
|
This page explains how to use JKQTPlotter in your own Projects
|
|
|
|
\tableofcontents
|
|
|
|
\section page_buildinstructions_CMAKE Build using CMake
|
|
|
|
\subsection page_buildinstructions_CMAKE_RUN Running a Build with CMake
|
|
|
|
The preferred way to build JKQTPlotter is using <a href="https://cmake.org/">CMake</a>. The CMake-build is defined in `CMakeLists.txt` files, found in many of the directories of the code repository.
|
|
|
|
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
|
|
|
|
You can use (MinGW) Makefiles by calling:
|
|
|
|
\code{.sh}
|
|
$ mkdir build
|
|
$ cd build
|
|
$ cmake .. -G "MinGW Makefiles" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>"
|
|
$ cmake --build . --config "Debug"
|
|
\endcode
|
|
|
|
\subsubsection page_buildinstructions_CMAKE_VSTUDIO Building with Visual Studio
|
|
|
|
For Visual Studio it could look like this:
|
|
\code{.sh}
|
|
$ mkdir build
|
|
$ cd build
|
|
$ cmake .. -G "Visual Studio 15 2017 Win64" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>"
|
|
\endcode
|
|
Where \c <path_to_your_qt_sources> could be e.g. \c C:/development/Qt5/5.12.0/msvc2017_64 . 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:
|
|
\code{.sh}
|
|
$ cmake --build . --config "Debug"
|
|
\endcode
|
|
|
|
|
|
|
|
\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
|
|
- \c BUILD_SHARED_LIBS : Build as shared library (default: \c ON )
|
|
- \c BUILD_STATIC_LIBS : Build as static library (default: \c ON )
|
|
- \c BUILD_INCLUDE_XITS_FONTS : Include XITS fonts as resources in library (default: \c ON )
|
|
- \c BUILD_DECORATE_LIBNAMES_WITH_BUILDTYPE : If set, the build-type is appended to the library name (default: \c ON )
|
|
- \c BUILD_HIGH_COMPILE_WARNING_LEVEL : Set Compiler Warning level to high (default: \c OFF )
|
|
- \c BUILD_EXAMPLES : Build examples (default: \c ON )
|
|
- \c BUILD_HAS_OPENCV : OpenCV available? If yes, OpenCV examples are built when BUILD_EXAMPLES=ON (default: \c OFF )
|
|
- \c LIB_INSTALL : Install library (default: \c ON )
|
|
- \c CMAKE_INSTALL_PREFIX : Install directory (default: \c${CMAKE_CURRENT_SOURCE_DIR}/install )
|
|
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\section page_buildinstructions_QMAKE Build using QMake
|
|
|
|
\subsection page_buildinstructions_QMAKEINCLUDE QMake Include Project
|
|
|
|
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:
|
|
\code{.qmake}
|
|
include(<PATHTOJKQTPLOTTERDIR>/lib/jkqtplotter.pri)
|
|
\endcode
|
|
|
|
\subsection page_buildinstructions_QMAKESTATIC QMake Static Library
|
|
|
|
There are several `.PRO`-files, that can be used to build the full library, or a limited subsets of it as static link library:
|
|
- <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
|
|
.
|
|
They will produce a static link library that you can include into your projects, e.g. with the following QMake-snippet:
|
|
|
|
\code{.qmake}
|
|
# include JKQTPlotter library
|
|
DEPENDPATH += \
|
|
<PATHTOJKQTPLOTTERDIR>/lib \
|
|
<PATHTOJKQTPLOTTERDIR>/qmake/staticlib/jkqtplotterlib
|
|
INCLUDEPATH += <PATHTOJKQTPLOTTERDIR>/lib
|
|
CONFIG (debug, debug|release) {
|
|
DEPENDPATH += <PATHTOJKQTPLOTTERDIR>/qmake/staticlib/jkqtplotterlib/debug
|
|
LIBS += -L<PATHTOJKQTPLOTTERDIR>/qmake/staticlib/jkqtplotterlib/debug -ljkqtplotterlib_debug
|
|
} else {
|
|
DEPENDPATH += <PATHTOJKQTPLOTTERDIR>/qmake/staticlib/jkqtplotterlib/release
|
|
LIBS += -L<PATHTOJKQTPLOTTERDIR>/qmake/staticlib/jkqtplotterlib/release -ljkqtplotterlib
|
|
}
|
|
\endcode
|
|
|
|
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:
|
|
\code{.qmake}
|
|
TEMPLATE = subdirs
|
|
|
|
# the (static library version) of JKQTPlotter
|
|
jkqtplotterlib_static.file = ../../qmake/staticlib/jkqtplotterlib/jkqtplotterlib.pro
|
|
|
|
# your project file, with declared dependencies on jkqtplotterlib_static
|
|
test_styling.file=$$PWD/test_styling.pro
|
|
test_styling.depends = jkqtplotterlib_static
|
|
|
|
# add the two entries to SUBDIRS
|
|
SUBDIRS += jkqtplotterlib_static test_styling
|
|
\endcode
|
|
|
|
|
|
|
|
\subsection page_buildinstructions_QMAKEDYNAMIC QMake Dynamic Library
|
|
|
|
There are several `.PRO`-files, that can be used to build the full library, or a limited subsets of it as shred library:
|
|
- <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
|
|
.
|
|
They will produce a dynamic link library that you can include into your projects, e.g. with the following QMake-snippet:
|
|
|
|
\code{.qmake}
|
|
# include JKQTPlotter library
|
|
DEPENDPATH += \
|
|
<PATHTOJKQTPLOTTERDIR>/lib \
|
|
<PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib
|
|
INCLUDEPATH += <PATHTOJKQTPLOTTERDIR>/lib
|
|
DEFINES += JKQTCOMMON_LIB_IN_DLL JKQTFASTPLOTTER_LIB_IN_DLL JKQTMATHTEXT_LIB_IN_DLL JKQTPLOTTER_LIB_IN_DLL
|
|
CONFIG (debug, debug|release) {
|
|
# ensure that DLLs are copied to the output directory
|
|
install_jkqtplotter_dll.files = <PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/debug/jkqtplotterlib_debug.*
|
|
install_jkqtplotter_dll.path = $$OUT_PWD
|
|
INSTALLS += install_jkqtplotter_dll
|
|
# link agains DLLs
|
|
DEPENDPATH += <PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/debug
|
|
LIBS += -L<PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/debug -ljkqtplotterlib_debug
|
|
} else {
|
|
# ensure that DLLs are copied to the output directory
|
|
install_jkqtplotter_dll.files = <PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/release/jkqtplotterlib.*
|
|
install_jkqtplotter_dll.path = $$OUT_PWD
|
|
INSTALLS += install_jkqtplotter_dll
|
|
# link agains DLLs
|
|
DEPENDPATH += <PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/release
|
|
LIBS += -L<PATHTOJKQTPLOTTERDIR>/qmake/sharedlib/jkqtplotterlib/release -ljkqtplotterlib
|
|
}
|
|
\endcode
|
|
|
|
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:
|
|
\code{.qmake}
|
|
TEMPLATE = subdirs
|
|
|
|
# the (shared library version) of JKQTPlotter
|
|
jkqtplotterlib_shared.file = ../../qmake/sharedlib/jkqtplotterlib.pro
|
|
|
|
# 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).
|
|
|
|
|
|
|
|
|
|
|
|
*/ |