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