1- #: # CMakeLists.txt ([source](../appskeleton/CMakeLists.txt))
2- #:
3- #: `CMakeLists.txt` contains the build configuration that can be used to build
4- #: your App without any IDE or to generate project files for your specific IDE.
5- #:
6- #: ## Required settings for all apps
7- cmake_minimum_required (VERSION 3.5 )
8-
9- #: This sets the minimum required CMake version.
10- #: Here, [CMake 3.5](https://cmake.org/cmake/help/latest/release/3.5.html#modules)
11- #: was chosen because it is the first version to support imported targets
12- #: (e.g. `boost::thread`). Before setting this to a higher version, please check
13- #: if it has arrived in [debian stable](https://packages.debian.org/stable/cmake).
14- project (BestPracticesGUI
1+ # CMakeLists.txt contains the build configuration that can be used to build
2+ # your App without any IDE or to generate project files for your specific IDE.
3+ # First, set the minimum required CMake version.
4+ # Here, [CMake 3.10](https://cmake.org/cmake/help/latest/release/3.10.html)
5+ # was chosen. Before setting this to a higher version, please check
6+ # if it has arrived in
7+ # debian stable https://packages.debian.org/stable/cmake
8+ # and Ubuntu LTS https://packages.ubuntu.com/bionic/cmake
9+ cmake_minimum_required (VERSION 3.10 )
10+
11+ project (AppTemplate_cpp_qt
1512 LANGUAGES CXX
16- VERSION 1.13.0)
17-
18- #: [project](https://cmake.org/cmake/help/latest/command/project.html) sets the
19- #: name of the app, the languages used and the version. The version is later on
20- #: used in the packages CMake creates for your app.
21-
22- #: ## Finding liblsl
23- #:
24- #: Your app most likely requires liblsl, so CMake has to find it.
25- #:
26- #: The easiest way to find it using the Findliblsl.cmake find-module in the cmake subfolder.
27- #: The newest version of Findliblsl.cmake should be available in the template app
28- #: repository [here](https://github.com/labstreaminglayer/AppTemplate_cpp_qt/blob/master/cmake/Findliblsl.cmake).
13+ VERSION 1.13.0
14+ )
2915
16+ # also look for CMake modules in the cmake subfolder
3017list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
3118
32- #: First we need to tell cmake to search in the `cmake` subfolder for cmake find-modules.
33-
34- find_package (liblsl REQUIRED )
19+ # Find an installed liblsl in paths set by the user (LSL_INSTALL_ROOT)
20+ # and some default paths
21+ find_package (LSL REQUIRED
22+ HINTS ${LSL_INSTALL_ROOT}
23+ "${CMAKE_CURRENT_LIST_DIR} /../../LSL/liblsl/build/"
24+ "${CMAKE_CURRENT_LIST_DIR} /../../LSL/liblsl/out/build/x64-Release"
25+ PATH_SUFFIXES share/LSL )
26+ get_filename_component (LSL_PATH ${LSL_CONFIG} DIRECTORY )
27+ message (STATUS "Found LSL lib in ${LSL_PATH} " )
28+ LSLAPP_Setup_Boilerplate ()
3529
3630#: Then we can simply use find_package. This enables us to later link LSL::lsl
3731#: You can read more about [find_package](https://cmake.org/cmake/help/latest/command/find_package.html).
@@ -85,31 +79,22 @@ set(CMAKE_AUTORCC ON)
8579
8680find_package (Qt5 REQUIRED COMPONENTS Widgets )
8781
88-
89- #: ## Native threads
90- #:
91- #: Native `std::thread`s still require a platform thread library. CMake
92- #: can find and link to it with the `Threads` package (link your executable with
93- #: `Threads::Threads` afterwards).
94-
82+ # Native `std::thread`s still require a platform thread library.
83+ # CMake can find and link to it with the `Threads` package (link your
84+ # executable with `Threads::Threads` afterwards).
9585find_package (Threads REQUIRED )
9686
97-
98- #: If everything succeeds, you can link your app with the vendor SDK
99- #: by linking to the imported target.
100- #:
101- #: ## Creating executables for your app
102- #:
103- #: Your app can have multiple executables. All of them are set up the same way:
87+ # Add executable targets, the default target has the same name as the project
10488
10589add_executable (${PROJECT_NAME} MACOSX_BUNDLE WIN32
10690 main.cpp
10791 mainwindow.cpp
108- mainwindow.h
92+ mainwindow.hpp
10993 mainwindow.ui
110- reader.h
94+ reader.hpp
11195 reader.cpp
11296)
97+
11398target_link_libraries (${PROJECT_NAME}
11499 PRIVATE
115100 Qt5::Widgets
@@ -118,47 +103,11 @@ target_link_libraries(${PROJECT_NAME}
118103# Vendor::DeviceModule
119104)
120105
121- set_property (TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
122- # target_compile_features(${PROJECT_NAME} PRIVATE cxx_auto_type cxx_lambda_init_captures)
123-
124- #: [add_executable](https://cmake.org/cmake/help/latest/command/add_executable.html)
125- #: tells CMake to take all files listed (even Qt `.ui` files), compile them and
126- #: link them together. `MACOSX_BUNDLE` creates a bundle on OS X, `WIN32` tells
127- #: Windows compilers not to show a command line window when launching the app.
128- #:
129- #: Using `${PROJECT_NAME}` as a placeholder for the executable name makes it easier
130- #: to reuse parts of the `CMakeLists.txt` in other projects.
131- #:
132- #: [target_link_libraries](https://cmake.org/cmake/help/latest/command/target_link_libraries.html)
133- #: tells CMake to add the include paths (and if necessary `#define`s) to the
134- #: compiler command line and link to the libraries when producing a binary.
135- #:
136- #: If you want to use newer C++ features, either set the target standard version via
137- #: [`set_property(... CXX_STANDARD 11)`](https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html)
138- #: or explicitly enable features you need with
139- #: [`target_compile_features`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html)
140- #: (see [`CMAKE_CXX_KNOWN_FEATURES`](https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES)
141- #: for a list.
142- #:
143- #: ## Setting up deployment
144- #:
145- #: You can also let CMake generate a zip / dmg file with everything needed to run
146- #: your app:
106+ target_compile_features (${PROJECT_NAME} PRIVATE cxx_std_14 )
147107
108+ # Setting up deployment (let CPack generate a zip/dmg file)
148109installLSLApp (${PROJECT_NAME} )
149110installLSLAuxFiles (${PROJECT_NAME}
150111 ${PROJECT_NAME} .cfg
151112)
152-
153113LSLGenerateCPackConfig ()
154- #: `installLSLApp` creates an install target for the binary target, so that the
155- #: CMake install target creates a directory for your app and copies the binary
156- #: and all needed libraries (including Qt) to this folder.
157- #:
158- #: `installLSLAuxFiles` copies additional files needed (e.g. config files) to the
159- #: distribution directory.
160- #:
161- #: `LSLGenerateCPackConfig` (has to be the last line!) generates a
162- #: [CPack](https://cmake.org/Wiki/CMake:Packaging_With_CPack) configuration.
163- #: CPack will then create packages (`.deb` on Linux, `.dmg` on OS X, `.zip` on
164- #: Windows) that are easy to send someone and install on another computer.
0 commit comments