# Example (JKQTPlotter): CMake Example {#JKQTCMakeLinkExample} This project (see [`cmake_link_example`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/cmake_link_example) demonstrates how to link against JKQTPlotter using CMake. See http://jkriege2.github.io/JKQtPlotter/page_buildinstructions.html for details on how to build JKQTPlotter with CMake This example uses very simple code, which simply displays a plotter and shows some data. The important part of this example is the ´CMakeLists.txt`-file: ``` # set minimum required CMake-Version cmake_minimum_required(VERSION 3.0) # set Project name set(EXAMPLE_NAME simpletest) set(EXENAME jkqtptest_${EXAMPLE_NAME}) project(${EXAMPLE_NAME} LANGUAGES CXX) # some basic configurations set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Configure project for usage of Qt5 find_package(Qt5 5.12 REQUIRED Core Gui Widgets PrintSupport Svg Xml OpenGl) # include JKQTPlotter find_package(JKQTCommonLib) find_package(JKQTMathTextLib) find_package(JKQTPlotterLib) # For Visual Studio, we need to set some additional compiler options if(MSVC) add_compile_options(/EHsc) # To enable M_PI, M_E,... add_definitions(/D_USE_MATH_DEFINES) # To Prevent Errors with min() and max() add_definitions(/DNOMINMAX) # To fix error: C2338: va_start argument must not # have reference type and must not be parenthesized add_definitions(/D_CRT_NO_VA_START_VALIDATION) endif() # add the example executable add_executable(${EXENAME} WIN32 simpletest.cpp) # ... and link against JKQTPlotterLib # (you could use JKQTPlotterSharedLib if you don't want to link againast the # static version, but against the shared/DLL version). target_link_libraries(${EXENAME} JKQTPlotterLib) ``` To build this example, you first need to make a subdirectory `build` and then call CMake form that subdirectory: ```.sh $ mkdir build $ cd build $ cmake .. -G "" "-DCMAKE_PREFIX_PATH= -DCMAKE_MODULE_PATH=" ``` The you can use the generated makefiles (e.g. load them in an editor, or build them jsing `make`). In the last line above, you need to specify two directories: - `` points to you Qt installation - `` points to the directory containing the `XYZ.cmake`-files from the JKQTPlotter build. Typically this is `/lib/cmake`, where `` is the directory into which you installed JKQTPlotter.