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