]>
Commit | Line | Data |
---|---|---|
0aad432c | 1 | ## |
190fc91a | 2 | ## This file is part of the PulseView project. |
68c4a3b3 JH |
3 | ## |
4 | ## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
3933e8a9 | 5 | ## Copyright (C) 2012-2013 Alexandru Gagniuc <mr.nuke.me@gmail.com> |
10f5e6f5 | 6 | ## Copyright (C) 2020 Soeren Apel <soeren@apelpie.net> |
68c4a3b3 JH |
7 | ## |
8 | ## This program is free software: you can redistribute it and/or modify | |
9 | ## it under the terms of the GNU General Public License as published by | |
10 | ## the Free Software Foundation, either version 2 of the License, or | |
11 | ## (at your option) any later version. | |
12 | ## | |
13 | ## This program is distributed in the hope that it will be useful, | |
14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ## GNU General Public License for more details. | |
17 | ## | |
18 | ## You should have received a copy of the GNU General Public License | |
19 | ## along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | ## | |
21 | ||
e222f01e | 22 | cmake_minimum_required(VERSION 2.8.12) |
0cf9fb24 | 23 | |
52bbe600 | 24 | include(GNUInstallDirs) |
df944399 | 25 | |
a8d3fb2d | 26 | project(pulseview) |
df944399 | 27 | |
3782d860 UH |
28 | # Let AUTOMOC and AUTOUIC process GENERATED files. |
29 | if(POLICY CMP0071) | |
30 | cmake_policy(SET CMP0071 NEW) | |
31 | endif() | |
32 | ||
33 | # Only interpret if() arguments as variables or keywords when unquoted. | |
34 | if(POLICY CMP0054) | |
35 | cmake_policy(SET CMP0054 NEW) | |
36 | endif() | |
37 | ||
cf2b5b64 UH |
38 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") |
39 | ||
30588653 | 40 | #=============================================================================== |
506523c1 JH |
41 | #= User Options |
42 | #------------------------------------------------------------------------------- | |
43 | ||
3782d860 | 44 | option(DISABLE_WERROR "Build without -Werror" TRUE) |
140181a4 | 45 | option(ENABLE_SIGNALS "Build with UNIX signals" TRUE) |
3782d860 | 46 | option(ENABLE_STACKTRACE "Enable stack trace when crashing" FALSE) |
19f511a4 | 47 | option(ENABLE_DECODE "Build with libsigrokdecode" TRUE) |
10f5e6f5 | 48 | option(ENABLE_FLOW "Build with libsigrokflow" FALSE) |
3782d860 | 49 | option(ENABLE_TESTS "Enable unit tests" FALSE) |
61e1e13e | 50 | option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE) |
b04e278d AG |
51 | |
52 | if(WIN32) | |
7d297a01 UH |
53 | # On Windows/MinGW we need to statically link to libraries. |
54 | # This option is user configurable, but enable it by default on win32. | |
b04e278d | 55 | set(STATIC_PKGDEPS_LIBS TRUE) |
6987ceeb | 56 | |
0aad432c | 57 | # Windows does not support UNIX signals. |
140181a4 | 58 | set(ENABLE_SIGNALS FALSE) |
b04e278d | 59 | endif() |
506523c1 | 60 | |
552f686e | 61 | if(NOT CMAKE_BUILD_TYPE) |
7591fe23 UH |
62 | set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING |
63 | "Choose the type of build (None, Debug, Release, RelWithDebInfo, MinSizeRel)." | |
64 | FORCE) | |
552f686e JH |
65 | endif() |
66 | ||
3782d860 UH |
67 | #=============================================================================== |
68 | #= Documentation | |
69 | #------------------------------------------------------------------------------- | |
70 | ||
71 | add_subdirectory(manual) | |
72 | ||
506523c1 | 73 | #=============================================================================== |
30588653 AG |
74 | #= Dependencies |
75 | #------------------------------------------------------------------------------- | |
76 | ||
e1e2666e | 77 | list(APPEND PKGDEPS glib-2.0>=2.28.0) |
d93ac5e8 UH |
78 | list(APPEND PKGDEPS glibmm-2.4>=2.28.0) |
79 | ||
10f5e6f5 UH |
80 | if(ENABLE_FLOW) |
81 | list(APPEND PKGDEPS gstreamermm-1.0>=1.8.0) | |
82 | list(APPEND PKGDEPS libsigrokflow>=0.1.0) | |
83 | endif() | |
84 | ||
3782d860 UH |
85 | set(LIBSR_CXX_BINDING "libsigrokcxx>=0.5.1") |
86 | list(APPEND PKGDEPS "${LIBSR_CXX_BINDING}") | |
df944399 | 87 | |
269528f5 | 88 | if(ENABLE_DECODE) |
3782d860 | 89 | list(APPEND PKGDEPS libsigrokdecode>=0.5.2) |
269528f5 JH |
90 | endif() |
91 | ||
aff51746 MC |
92 | if(ANDROID) |
93 | list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) | |
94 | endif() | |
95 | ||
d52d8455 | 96 | find_package(PkgConfig) |
10f5e6f5 | 97 | pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING}) |
3782d860 UH |
98 | if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION) |
99 | message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)") | |
100 | endif() | |
d52d8455 JH |
101 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) |
102 | ||
e222f01e | 103 | set(CMAKE_AUTOMOC TRUE) |
e222f01e | 104 | |
10f5e6f5 UH |
105 | find_package(Qt5 5.3 COMPONENTS Core Gui LinguistTools Widgets Svg REQUIRED) |
106 | ||
107 | message(STATUS "Qt version: ${Qt5_VERSION}") | |
e7ab88e3 | 108 | |
09f55d96 UH |
109 | if(WIN32) |
110 | # MXE workaround: Use pkg-config to find Qt5 libs. | |
111 | # https://github.com/mxe/mxe/issues/1642 | |
3782d860 UH |
112 | # Not required (and doesn't work) on MSYS2. |
113 | if(NOT DEFINED ENV{MSYSTEM}) | |
10f5e6f5 | 114 | pkg_check_modules(QT5ALL REQUIRED Qt5Widgets>=5.3 Qt5Gui>=5.3 Qt5Svg>=5.3) |
3782d860 | 115 | endif() |
09f55d96 | 116 | endif() |
9e8e84fc | 117 | |
e7ab88e3 | 118 | set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg) |
2e2946fe | 119 | |
b8f1cdeb | 120 | set(BOOSTCOMPS filesystem serialization system) |
226a1527 | 121 | if(ENABLE_TESTS) |
d68d75c2 | 122 | list(APPEND BOOSTCOMPS unit_test_framework) |
2a21747e | 123 | endif() |
3782d860 UH |
124 | |
125 | if(ENABLE_STACKTRACE) | |
126 | find_package(Boost 1.65.1 COMPONENTS ${BOOSTCOMPS} REQUIRED) | |
127 | else() | |
128 | find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED) | |
129 | endif() | |
df944399 | 130 | |
858ae630 UH |
131 | # Find the platform's thread library (needed for C++11 threads). |
132 | # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. | |
2b76309a AJ |
133 | find_package(Threads REQUIRED) |
134 | ||
4da54b6b SM |
135 | # Check for explicit link against libatomic |
136 | # | |
137 | # Depending on the toolchain, linking a program using atomic functions may need | |
138 | # "-latomic" explicitly passed to the linker | |
139 | # | |
140 | # This check first tests if atomics are available in the C-library, if not and | |
141 | # libatomic exists, then it runs the same test with -latomic added to the | |
142 | # linker flags. | |
143 | ||
144 | # Helper for checking for atomics | |
145 | function(check_working_cxx_atomics varname additional_lib) | |
146 | include(CheckCXXSourceCompiles) | |
147 | include(CMakePushCheckState) | |
148 | cmake_push_check_state() | |
149 | set(CMAKE_REQUIRED_FLAGS "-std=c++11") | |
150 | set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}") | |
151 | set(CMAKE_REQUIRED_QUIET 1) | |
152 | CHECK_CXX_SOURCE_COMPILES(" | |
153 | #include <atomic> | |
154 | std::atomic<int> x; | |
155 | int main() { | |
156 | return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst); | |
157 | } | |
158 | " ${varname}) | |
159 | cmake_pop_check_state() | |
160 | endfunction(check_working_cxx_atomics) | |
161 | ||
162 | # First check if atomics work without the library. | |
163 | # If not, check if the library exists, and atomics work with it. | |
164 | check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB "") | |
165 | if(HAVE_CXX_ATOMICS_WITHOUT_LIB) | |
166 | message(STATUS "Atomics provided by the C-library - yes") | |
167 | else() | |
168 | message(STATUS "Atomics provided by the C-library - no") | |
169 | find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib) | |
170 | if(LIBATOMIC_LIBRARY) | |
171 | check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}") | |
172 | if (HAVE_CXX_ATOMICS_WITH_LIB) | |
173 | message(STATUS "Atomics provided by libatomic - yes") | |
174 | else() | |
175 | message(STATUS "Atomics provided by libatomic - no") | |
176 | message(FATAL_ERROR "Compiler must support std::atomic!") | |
177 | endif() | |
178 | else() | |
179 | message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.") | |
180 | endif() | |
181 | endif() | |
182 | ||
9df8453f MC |
183 | #=============================================================================== |
184 | #= System Introspection | |
185 | #------------------------------------------------------------------------------- | |
186 | ||
187 | include(memaccess) | |
188 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
189 | ||
075fb499 AG |
190 | #=============================================================================== |
191 | #= Config Header | |
192 | #------------------------------------------------------------------------------- | |
193 | ||
f7951df4 | 194 | set(PV_TITLE PulseView) |
05a4de8a | 195 | set(PV_VERSION_STRING "0.4.1") |
f7951df4 | 196 | |
d93ac5e8 UH |
197 | set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION}) |
198 | ||
1e8c82e9 | 199 | include(GetGitRevisionDescription) |
1e8c82e9 | 200 | |
812c0e35 DE |
201 | # Append the revision hash unless we are exactly on a tagged release. |
202 | git_describe(PV_TAG_VERSION_STRING --match "pulseview-${PV_VERSION_STRING}" --exact-match) | |
203 | if(NOT PV_TAG_VERSION_STRING) | |
204 | get_git_head_revision(PV_REVSPEC PV_HASH) | |
205 | if(PV_HASH) | |
206 | string(SUBSTRING "${PV_HASH}" 0 7 PV_SHORTHASH) | |
207 | set(PV_VERSION_STRING "${PV_VERSION_STRING}-git-${PV_SHORTHASH}") | |
d69b3c31 | 208 | endif() |
3782d860 UH |
209 | |
210 | # Non-tagged releases use the unstable manual | |
211 | set(PV_MANUAL_VERSION "unstable") | |
212 | else() | |
213 | # Tagged releases use a fixed manual version | |
214 | set(PV_MANUAL_VERSION ${PV_VERSION_STRING}) | |
d69b3c31 DE |
215 | endif() |
216 | ||
217 | if(PV_VERSION_STRING MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-[-0-9a-z]*)?$") | |
1e8c82e9 DE |
218 | set(PV_VERSION_MAJOR ${CMAKE_MATCH_1}) |
219 | set(PV_VERSION_MINOR ${CMAKE_MATCH_2}) | |
220 | set(PV_VERSION_MICRO ${CMAKE_MATCH_3}) | |
221 | set(PV_VERSION_SUFFIX ${CMAKE_MATCH_4}) | |
1e8c82e9 DE |
222 | endif() |
223 | ||
3782d860 | 224 | message(STATUS "${PV_TITLE} version: ${PV_VERSION_STRING}") |
075fb499 AG |
225 | |
226 | configure_file ( | |
227 | ${PROJECT_SOURCE_DIR}/config.h.in | |
228 | ${PROJECT_BINARY_DIR}/config.h | |
229 | ) | |
df944399 | 230 | |
30588653 AG |
231 | #=============================================================================== |
232 | #= Sources | |
233 | #------------------------------------------------------------------------------- | |
234 | ||
a8d3fb2d | 235 | set(pulseview_SOURCES |
df944399 | 236 | main.cpp |
dac1bb97 | 237 | pv/application.cpp |
107ca6d3 | 238 | pv/devicemanager.cpp |
bf9f1268 | 239 | pv/globalsettings.cpp |
3782d860 | 240 | pv/logging.cpp |
51e77110 | 241 | pv/mainwindow.cpp |
f65cd27b | 242 | pv/session.cpp |
0fbda3c2 | 243 | pv/storesession.cpp |
f0c9f81c | 244 | pv/util.cpp |
61703a01 | 245 | pv/binding/binding.cpp |
0c913637 | 246 | pv/binding/inputoutput.cpp |
3cc9ad7b | 247 | pv/binding/device.cpp |
1b1ec774 | 248 | pv/data/analog.cpp |
f3d66e52 | 249 | pv/data/analogsegment.cpp |
1b1ec774 | 250 | pv/data/logic.cpp |
f3d66e52 | 251 | pv/data/logicsegment.cpp |
bf0edd2b | 252 | pv/data/signalbase.cpp |
1b1ec774 | 253 | pv/data/signaldata.cpp |
f3d66e52 | 254 | pv/data/segment.cpp |
da30ecb7 | 255 | pv/devices/device.cpp |
474e817a | 256 | pv/devices/file.cpp |
da30ecb7 | 257 | pv/devices/hardwaredevice.cpp |
5237f0c5 | 258 | pv/devices/inputfile.cpp |
da30ecb7 | 259 | pv/devices/sessionfile.cpp |
9663c82b | 260 | pv/dialogs/connect.cpp |
e93f5538 | 261 | pv/dialogs/inputoutputoptions.cpp |
bf9f1268 | 262 | pv/dialogs/settings.cpp |
0fbda3c2 | 263 | pv/dialogs/storeprogress.cpp |
51d4a9ab | 264 | pv/popups/deviceoptions.cpp |
6ac6242b | 265 | pv/popups/channels.cpp |
de1d99bb | 266 | pv/prop/bool.cpp |
b912c99c | 267 | pv/prop/double.cpp |
820c3dea | 268 | pv/prop/enum.cpp |
a2b92157 | 269 | pv/prop/int.cpp |
c8df6005 | 270 | pv/prop/property.cpp |
7112a458 | 271 | pv/prop/string.cpp |
10f5e6f5 | 272 | pv/subwindows/subwindowbase.cpp |
7c657094 | 273 | pv/toolbars/mainbar.cpp |
1573bf16 SA |
274 | pv/views/trace/analogsignal.cpp |
275 | pv/views/trace/cursor.cpp | |
276 | pv/views/trace/cursorpair.cpp | |
277 | pv/views/trace/flag.cpp | |
278 | pv/views/trace/header.cpp | |
279 | pv/views/trace/marginwidget.cpp | |
280 | pv/views/trace/logicsignal.cpp | |
1573bf16 SA |
281 | pv/views/trace/ruler.cpp |
282 | pv/views/trace/signal.cpp | |
1573bf16 SA |
283 | pv/views/trace/timeitem.cpp |
284 | pv/views/trace/timemarker.cpp | |
285 | pv/views/trace/trace.cpp | |
286 | pv/views/trace/tracegroup.cpp | |
287 | pv/views/trace/tracepalette.cpp | |
288 | pv/views/trace/tracetreeitem.cpp | |
289 | pv/views/trace/tracetreeitemowner.cpp | |
290 | pv/views/trace/triggermarker.cpp | |
291 | pv/views/trace/view.cpp | |
292 | pv/views/trace/viewitem.cpp | |
293 | pv/views/trace/viewitemowner.cpp | |
294 | pv/views/trace/viewitempaintparams.cpp | |
295 | pv/views/trace/viewport.cpp | |
296 | pv/views/trace/viewwidget.cpp | |
f4e57597 | 297 | pv/views/viewbase.cpp |
e0ba4f6f | 298 | pv/views/trace/standardbar.cpp |
3782d860 UH |
299 | pv/widgets/colorbutton.cpp |
300 | pv/widgets/colorpopup.cpp | |
079d39ea | 301 | pv/widgets/devicetoolbutton.cpp |
ce6001b8 | 302 | pv/widgets/exportmenu.cpp |
10f5e6f5 | 303 | pv/widgets/flowlayout.cpp |
56b6fc88 | 304 | pv/widgets/importmenu.cpp |
6e3f046e | 305 | pv/widgets/popup.cpp |
6a91973f | 306 | pv/widgets/popuptoolbutton.cpp |
1198b887 | 307 | pv/widgets/sweeptimingwidget.cpp |
806d3e1e | 308 | pv/widgets/timestampspinbox.cpp |
0c0e1888 | 309 | pv/widgets/wellarray.cpp |
df944399 JH |
310 | ) |
311 | ||
0aad432c | 312 | # This list includes only QObject derived class headers. |
a8d3fb2d | 313 | set(pulseview_HEADERS |
3782d860 | 314 | pv/logging.hpp |
bf9f1268 | 315 | pv/globalsettings.hpp |
2acdb232 | 316 | pv/mainwindow.hpp |
f65cd27b | 317 | pv/session.hpp |
2acdb232 | 318 | pv/storesession.hpp |
3cc9ad7b | 319 | pv/binding/device.hpp |
7db61e77 SA |
320 | pv/data/analog.hpp |
321 | pv/data/analogsegment.hpp | |
322 | pv/data/logic.hpp | |
323 | pv/data/logicsegment.hpp | |
bf0edd2b | 324 | pv/data/signalbase.hpp |
2acdb232 | 325 | pv/dialogs/connect.hpp |
e93f5538 | 326 | pv/dialogs/inputoutputoptions.hpp |
bf9f1268 | 327 | pv/dialogs/settings.hpp |
2acdb232 JH |
328 | pv/dialogs/storeprogress.hpp |
329 | pv/popups/channels.hpp | |
330 | pv/popups/deviceoptions.hpp | |
331 | pv/prop/bool.hpp | |
332 | pv/prop/double.hpp | |
333 | pv/prop/enum.hpp | |
334 | pv/prop/int.hpp | |
335 | pv/prop/property.hpp | |
336 | pv/prop/string.hpp | |
10f5e6f5 | 337 | pv/subwindows/subwindowbase.hpp |
7c657094 | 338 | pv/toolbars/mainbar.hpp |
1573bf16 SA |
339 | pv/views/trace/analogsignal.hpp |
340 | pv/views/trace/cursor.hpp | |
341 | pv/views/trace/flag.hpp | |
342 | pv/views/trace/header.hpp | |
343 | pv/views/trace/logicsignal.hpp | |
344 | pv/views/trace/marginwidget.hpp | |
1573bf16 SA |
345 | pv/views/trace/ruler.hpp |
346 | pv/views/trace/signal.hpp | |
1573bf16 SA |
347 | pv/views/trace/timeitem.hpp |
348 | pv/views/trace/timemarker.hpp | |
349 | pv/views/trace/trace.hpp | |
350 | pv/views/trace/tracegroup.hpp | |
351 | pv/views/trace/tracetreeitem.hpp | |
352 | pv/views/trace/triggermarker.hpp | |
353 | pv/views/trace/view.hpp | |
354 | pv/views/trace/viewitem.hpp | |
355 | pv/views/trace/viewport.hpp | |
356 | pv/views/trace/viewwidget.hpp | |
f4e57597 | 357 | pv/views/viewbase.hpp |
e0ba4f6f | 358 | pv/views/trace/standardbar.hpp |
3782d860 UH |
359 | pv/widgets/colorbutton.hpp |
360 | pv/widgets/colorpopup.hpp | |
079d39ea | 361 | pv/widgets/devicetoolbutton.hpp |
ce6001b8 | 362 | pv/widgets/exportmenu.hpp |
10f5e6f5 | 363 | pv/widgets/flowlayout.hpp |
56b6fc88 | 364 | pv/widgets/importmenu.hpp |
2acdb232 JH |
365 | pv/widgets/popup.hpp |
366 | pv/widgets/popuptoolbutton.hpp | |
367 | pv/widgets/sweeptimingwidget.hpp | |
806d3e1e | 368 | pv/widgets/timestampspinbox.hpp |
2acdb232 | 369 | pv/widgets/wellarray.hpp |
df944399 JH |
370 | ) |
371 | ||
8b9056d4 UH |
372 | set(pulseview_RESOURCES |
373 | pulseview.qrc | |
374 | ) | |
375 | ||
140181a4 JH |
376 | if(ENABLE_SIGNALS) |
377 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
2acdb232 | 378 | list(APPEND pulseview_HEADERS signalhandler.hpp) |
140181a4 JH |
379 | endif() |
380 | ||
269528f5 JH |
381 | if(ENABLE_DECODE) |
382 | list(APPEND pulseview_SOURCES | |
3cc9ad7b | 383 | pv/binding/decoder.cpp |
3782d860 | 384 | pv/data/decodesignal.cpp |
269528f5 JH |
385 | pv/data/decode/annotation.cpp |
386 | pv/data/decode/decoder.cpp | |
f9101a91 JH |
387 | pv/data/decode/row.cpp |
388 | pv/data/decode/rowdata.cpp | |
10f5e6f5 UH |
389 | pv/subwindows/decoder_selector/item.cpp |
390 | pv/subwindows/decoder_selector/model.cpp | |
391 | pv/subwindows/decoder_selector/subwindow.cpp | |
392 | pv/views/decoder_binary/view.cpp | |
393 | pv/views/decoder_binary/QHexView.cpp | |
1573bf16 | 394 | pv/views/trace/decodetrace.cpp |
269528f5 JH |
395 | pv/widgets/decodergroupbox.cpp |
396 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
397 | ) |
398 | ||
399 | list(APPEND pulseview_HEADERS | |
3782d860 | 400 | pv/data/decodesignal.hpp |
10f5e6f5 UH |
401 | pv/subwindows/decoder_selector/subwindow.hpp |
402 | pv/views/decoder_binary/view.hpp | |
403 | pv/views/decoder_binary/QHexView.hpp | |
1573bf16 | 404 | pv/views/trace/decodetrace.hpp |
2acdb232 JH |
405 | pv/widgets/decodergroupbox.hpp |
406 | pv/widgets/decodermenu.hpp | |
269528f5 JH |
407 | ) |
408 | endif() | |
409 | ||
fe15e0bc UH |
410 | if(WIN32) |
411 | # Use the sigrok icon for the pulseview.exe executable. | |
412 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
413 | enable_language(RC) | |
61e1e13e | 414 | list(APPEND pulseview_SOURCES pulseviewico.rc) |
fe15e0bc UH |
415 | endif() |
416 | ||
9137928c | 417 | if(ANDROID) |
dddff2e7 DE |
418 | list(APPEND pulseview_SOURCES |
419 | android/assetreader.cpp | |
420 | android/loghandler.cpp | |
421 | ) | |
9137928c MC |
422 | endif() |
423 | ||
8b9056d4 UH |
424 | qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) |
425 | ||
10f5e6f5 UH |
426 | #=============================================================================== |
427 | #= Translations | |
428 | #------------------------------------------------------------------------------- | |
429 | ||
430 | file(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/l10n/*.ts) | |
431 | set_property(SOURCE ${TS_FILES} PROPERTY OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/l10n) | |
432 | if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) | |
433 | configure_file("translations.qrc" "translations.qrc" COPYONLY) | |
434 | endif () | |
435 | ||
436 | qt5_add_translation(QM_FILES ${TS_FILES}) | |
437 | qt5_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES}) | |
438 | ||
439 | qt5_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc) | |
440 | ||
30588653 AG |
441 | #=============================================================================== |
442 | #= Global Definitions | |
443 | #------------------------------------------------------------------------------- | |
444 | ||
e222f01e | 445 | add_definitions(-DQT_NO_KEYWORDS) |
ac223c1e | 446 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 447 | add_definitions(-Wall -Wextra) |
95d43108 | 448 | add_definitions(-std=c++11) |
a838ed7b | 449 | add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1) |
5f606159 | 450 | |
10f5e6f5 UH |
451 | if(ENABLE_FLOW) |
452 | add_definitions(-DENABLE_FLOW) | |
453 | endif() | |
454 | ||
269528f5 JH |
455 | if(ENABLE_DECODE) |
456 | add_definitions(-DENABLE_DECODE) | |
457 | endif() | |
458 | ||
5f606159 JH |
459 | if(NOT DISABLE_WERROR) |
460 | add_definitions(-Werror) | |
461 | endif() | |
df944399 | 462 | |
9632990d UH |
463 | if(ENABLE_SIGNALS) |
464 | add_definitions(-DENABLE_SIGNALS) | |
465 | endif() | |
466 | ||
3782d860 UH |
467 | if(ENABLE_STACKTRACE) |
468 | add_definitions(-DENABLE_STACKTRACE) | |
469 | endif() | |
470 | ||
30588653 AG |
471 | #=============================================================================== |
472 | #= Global Include Directories | |
473 | #------------------------------------------------------------------------------- | |
474 | ||
b04e278d AG |
475 | include_directories( |
476 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 477 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d AG |
478 | ${Boost_INCLUDE_DIRS} |
479 | ) | |
480 | ||
481 | if(STATIC_PKGDEPS_LIBS) | |
482 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
483 | else() | |
484 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
485 | endif() | |
df944399 | 486 | |
30588653 AG |
487 | #=============================================================================== |
488 | #= Linker Configuration | |
489 | #------------------------------------------------------------------------------- | |
490 | ||
b04e278d AG |
491 | link_directories(${Boost_LIBRARY_DIRS}) |
492 | ||
493 | set(PULSEVIEW_LINK_LIBS | |
494 | ${Boost_LIBRARIES} | |
495 | ${QT_LIBRARIES} | |
2b76309a | 496 | ${CMAKE_THREAD_LIBS_INIT} |
4da54b6b | 497 | ${LIBATOMIC_LIBRARY} |
b04e278d AG |
498 | ) |
499 | ||
500 | if(STATIC_PKGDEPS_LIBS) | |
cddf172d | 501 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) |
09f55d96 | 502 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LDFLAGS}) |
b04e278d | 503 | else() |
cddf172d UH |
504 | link_directories(${PKGDEPS_LIBRARY_DIRS}) |
505 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
b04e278d | 506 | endif() |
df944399 | 507 | |
11a04e2a UH |
508 | if(WIN32) |
509 | # On Windows we need to statically link the libqsvg imageformat | |
510 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
3782d860 UH |
511 | # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport (only for |
512 | # Qt < 5.8.0), and all Qt libs and their dependencies. | |
11a04e2a | 513 | add_definitions(-DQT_STATICPLUGIN) |
09f55d96 UH |
514 | list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin) |
515 | list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin) | |
3782d860 UH |
516 | if(Qt5Gui_VERSION VERSION_LESS 5.8.0) |
517 | list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport) | |
518 | endif() | |
519 | list(APPEND PULSEVIEW_LINK_LIBS ${QT5ALL_LDFLAGS}) | |
520 | endif() | |
521 | ||
522 | if(ENABLE_STACKTRACE) | |
523 | # Needed to resolve dladdr. | |
524 | list(APPEND PULSEVIEW_LINK_LIBS "-ldl") | |
11a04e2a UH |
525 | endif() |
526 | ||
9137928c MC |
527 | if(ANDROID) |
528 | list(APPEND PULSEVIEW_LINK_LIBS "-llog") | |
529 | endif() | |
530 | ||
10f5e6f5 | 531 | set(INPUT_FILES_LIST ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC} ${QM_FILES}) |
26807061 | 532 | if(ANDROID) |
10f5e6f5 | 533 | add_library(${PROJECT_NAME} SHARED ${INPUT_FILES_LIST}) |
26807061 | 534 | else() |
10f5e6f5 | 535 | add_executable(${PROJECT_NAME} ${INPUT_FILES_LIST}) |
26807061 | 536 | endif() |
df944399 | 537 | |
5a13850b | 538 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 539 | |
3782d860 | 540 | if(WIN32 AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") |
61e1e13e UH |
541 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
542 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
543 | endif() |
544 | ||
30588653 AG |
545 | #=============================================================================== |
546 | #= Installation | |
547 | #------------------------------------------------------------------------------- | |
548 | ||
52bbe600 | 549 | # Install the executable. |
cd6606c2 AG |
550 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
551 | ||
52bbe600 UH |
552 | # Install the manpage. |
553 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
554 | ||
96e282c4 UH |
555 | # Install the desktop file. |
556 | install(FILES contrib/org.sigrok.PulseView.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications) | |
557 | ||
22fc985b UH |
558 | # Install the AppData/AppStream file. |
559 | install(FILES contrib/org.sigrok.PulseView.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo) | |
560 | ||
09594425 UH |
561 | # Install the PulseView icons. |
562 | install(FILES icons/pulseview.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps) | |
563 | install(FILES icons/pulseview.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps) | |
564 | ||
f9cb49cc | 565 | # Generate Windows installer script. |
10f5e6f5 | 566 | configure_file(contrib/pulseview_cross.nsi.in ${CMAKE_CURRENT_BINARY_DIR}/contrib/pulseview_cross.nsi @ONLY) |
f9cb49cc | 567 | |
cd6606c2 AG |
568 | #=============================================================================== |
569 | #= Packaging (handled by CPack) | |
570 | #------------------------------------------------------------------------------- | |
571 | ||
b02a8cbf JH |
572 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
573 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
574 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
575 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
576 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
577 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
1e8c82e9 | 578 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PV_VERSION_STRING}") |
1d2fb87d | 579 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
580 | |
581 | include(CPack) | |
bc1c1462 | 582 | |
30588653 AG |
583 | #=============================================================================== |
584 | #= Tests | |
585 | #------------------------------------------------------------------------------- | |
586 | ||
77e8ac52 | 587 | if(ENABLE_TESTS) |
fb746bcc | 588 | add_subdirectory(test) |
951c583c | 589 | enable_testing() |
fb746bcc | 590 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 591 | endif() |