]> sigrok.org Git - pulseview.git/blame_incremental - CMakeLists.txt
manual: fix a clipboard error in PDF creation build rules
[pulseview.git] / CMakeLists.txt
... / ...
CommitLineData
1##
2## This file is part of the PulseView project.
3##
4## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5## Copyright (C) 2012-2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
6## Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
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
22cmake_minimum_required(VERSION 2.8.12)
23
24project(pulseview C CXX)
25
26include(GNUInstallDirs)
27
28# Let AUTOMOC and AUTOUIC process GENERATED files.
29if(POLICY CMP0071)
30 cmake_policy(SET CMP0071 NEW)
31endif()
32
33# Only interpret if() arguments as variables or keywords when unquoted.
34if(POLICY CMP0054)
35 cmake_policy(SET CMP0054 NEW)
36endif()
37
38list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
39
40#===============================================================================
41#= User Options
42#-------------------------------------------------------------------------------
43
44option(DISABLE_WERROR "Build without -Werror" TRUE)
45option(ENABLE_SIGNALS "Build with UNIX signals" TRUE)
46option(ENABLE_STACKTRACE "Enable stack trace when crashing" FALSE)
47option(ENABLE_DECODE "Build with libsigrokdecode" TRUE)
48option(ENABLE_FLOW "Build with libsigrokflow" FALSE)
49option(ENABLE_TESTS "Enable unit tests" FALSE)
50option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE)
51
52if(WIN32)
53 # On Windows/MinGW we need to statically link to libraries.
54 # This option is user configurable, but enable it by default on win32.
55 set(STATIC_PKGDEPS_LIBS TRUE)
56
57 # Windows does not support UNIX signals.
58 set(ENABLE_SIGNALS FALSE)
59endif()
60
61if(NOT CMAKE_BUILD_TYPE)
62 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
63 "Choose the type of build (None, Debug, Release, RelWithDebInfo, MinSizeRel)."
64 FORCE)
65endif()
66
67#===============================================================================
68#= Documentation
69#-------------------------------------------------------------------------------
70
71add_subdirectory(manual)
72
73#===============================================================================
74#= Dependencies
75#-------------------------------------------------------------------------------
76
77include(CheckCSourceCompiles)
78include(CheckCXXCompilerFlag)
79include(CheckCXXSourceCompiles)
80include(CMakePushCheckState)
81include(memaccess)
82
83find_package(PkgConfig)
84
85check_cxx_compiler_flag("-std=c++17" PV_HAVE_C++17)
86
87list(APPEND PKGDEPS glib-2.0>=2.28.0)
88
89# Try to find the prefered glibmm-2.4. If not found then add glibmm-2.68
90# to the dependency list.
91pkg_check_modules(GLIBMM_2_4 glibmm-2.4>2.28.0)
92if(GLIBMM_2_4_FOUND)
93 list(APPEND PKGDEPS glibmm-2.4>=2.28.0)
94else()
95 list(APPEND PKGDEPS glibmm-2.68>=2.68.0)
96endif()
97
98if(ENABLE_FLOW)
99 list(APPEND PKGDEPS gstreamermm-1.0>=1.8.0)
100 list(APPEND PKGDEPS libsigrokflow>=0.1.0)
101endif()
102
103set(LIBSR_CXX_BINDING "libsigrokcxx>=0.5.2")
104list(APPEND PKGDEPS "${LIBSR_CXX_BINDING}")
105
106if(ENABLE_DECODE)
107 list(APPEND PKGDEPS libsigrokdecode>=0.5.2)
108endif()
109
110if(ANDROID)
111 list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0)
112endif()
113
114pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING})
115if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION)
116 message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)")
117endif()
118pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
119
120set(CMAKE_AUTOMOC TRUE)
121
122find_package(Qt5 5.3 COMPONENTS Core Gui LinguistTools Widgets Svg REQUIRED)
123
124message(STATUS "Qt version: ${Qt5_VERSION}")
125
126if(WIN32)
127 # MXE workaround: Use pkg-config to find Qt5 libs.
128 # https://github.com/mxe/mxe/issues/1642
129 # Not required (and doesn't work) on MSYS2.
130 if(NOT DEFINED ENV{MSYSTEM})
131 pkg_check_modules(QT5ALL REQUIRED Qt5Widgets>=5.3 Qt5Gui>=5.3 Qt5Svg>=5.3)
132 endif()
133endif()
134
135set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
136
137set(BOOSTCOMPS filesystem serialization system)
138if(ENABLE_TESTS)
139 list(APPEND BOOSTCOMPS unit_test_framework)
140endif()
141
142if(ENABLE_STACKTRACE)
143 include(FindBacktrace)
144 if (Backtrace_FOUND)
145 set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
146 list(APPEND BOOSTCOMPS stacktrace_backtrace)
147 else()
148 set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp")
149 list(APPEND BOOSTCOMPS stacktrace_basic)
150 endif()
151 find_package(Boost 1.65.1 COMPONENTS ${BOOSTCOMPS} REQUIRED)
152else()
153 find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED)
154endif()
155
156# Find the platform's thread library (needed for C++11 threads).
157# This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
158find_package(Threads REQUIRED)
159
160# Check for explicit link against libatomic
161#
162# Depending on the toolchain, linking a program using atomic functions may need
163# "-latomic" explicitly passed to the linker
164#
165# This check first tests if atomics are available in the C-library, if not and
166# libatomic exists, then it runs the same test with -latomic added to the
167# linker flags.
168
169# Helper for checking for atomics
170function(check_working_cxx_atomics varname additional_lib)
171 cmake_push_check_state()
172 # The OSX 12 (Monteray) stdlib requires C++17 to compile.
173 if(APPLE AND PV_HAVE_C++17)
174 message(STATUS "Using C++17 for OSX build")
175 set(CMAKE_REQUIRED_FLAGS "-std=c++17")
176 else()
177 set(CMAKE_REQUIRED_FLAGS "-std=c++11")
178 endif()
179 set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}")
180 set(CMAKE_REQUIRED_QUIET 1)
181 CHECK_CXX_SOURCE_COMPILES("
182#include <atomic>
183std::atomic<int> x;
184int main() {
185 return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst);
186}
187" ${varname})
188 cmake_pop_check_state()
189endfunction(check_working_cxx_atomics)
190
191# First check if atomics work without the library.
192# If not, check if the library exists, and atomics work with it.
193check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB "")
194if(HAVE_CXX_ATOMICS_WITHOUT_LIB)
195 message(STATUS "Atomics provided by the C-library - yes")
196else()
197 message(STATUS "Atomics provided by the C-library - no")
198 find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib)
199 if(LIBATOMIC_LIBRARY)
200 check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}")
201 if (HAVE_CXX_ATOMICS_WITH_LIB)
202 message(STATUS "Atomics provided by libatomic - yes")
203 else()
204 message(STATUS "Atomics provided by libatomic - no")
205 message(FATAL_ERROR "Compiler must support std::atomic!")
206 endif()
207 else()
208 message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.")
209 endif()
210endif()
211
212# Check availability of features which depend on library versions.
213# TODO Ideally use check_symbol_exists() instead, reduce boilerplate.
214if(ENABLE_DECODE)
215 cmake_push_check_state()
216 set(CMAKE_REQUIRED_INCLUDES "${PKGDEPS_INCLUDE_DIRS}")
217 set(CMAKE_REQUIRED_LIBRARIES "sigrokdecode")
218 foreach (LPATH ${PKGDEPS_LIBRARY_DIRS})
219 list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-L${LPATH}")
220 endforeach ()
221 check_c_source_compiles("
222 #include <libsigrokdecode/libsigrokdecode.h>
223 int main(int argc, char *argv[])
224 {
225 (void)argc;
226 (void)argv;
227 return srd_session_send_eof(NULL);
228 }
229 " HAVE_SRD_SESSION_SEND_EOF)
230 cmake_pop_check_state()
231endif()
232
233#===============================================================================
234#= System Introspection
235#-------------------------------------------------------------------------------
236
237memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS)
238
239#===============================================================================
240#= Config Header
241#-------------------------------------------------------------------------------
242
243set(PV_TITLE PulseView)
244set(PV_VERSION_STRING "0.5.0")
245
246if(GLIBMM_2_4_FOUND)
247 set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION})
248else()
249 set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.68_VERSION})
250endif()
251
252include(GetGitRevisionDescription)
253
254# Append the revision hash unless we are exactly on a tagged release.
255git_describe(PV_TAG_VERSION_STRING --match "pulseview-${PV_VERSION_STRING}" --exact-match)
256if(NOT PV_TAG_VERSION_STRING)
257 get_git_head_revision(PV_REVSPEC PV_HASH)
258 if(PV_HASH)
259 string(SUBSTRING "${PV_HASH}" 0 7 PV_SHORTHASH)
260 set(PV_VERSION_STRING "${PV_VERSION_STRING}-git-${PV_SHORTHASH}")
261 endif()
262
263 # Non-tagged releases use the unstable manual
264 set(PV_MANUAL_VERSION "unstable")
265else()
266 # Tagged releases use a fixed manual version
267 set(PV_MANUAL_VERSION ${PV_VERSION_STRING})
268endif()
269
270if(PV_VERSION_STRING MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-[-0-9a-z]*)?$")
271 set(PV_VERSION_MAJOR ${CMAKE_MATCH_1})
272 set(PV_VERSION_MINOR ${CMAKE_MATCH_2})
273 set(PV_VERSION_MICRO ${CMAKE_MATCH_3})
274 set(PV_VERSION_SUFFIX ${CMAKE_MATCH_4})
275endif()
276
277message(STATUS "${PV_TITLE} version: ${PV_VERSION_STRING}")
278
279configure_file (
280 ${PROJECT_SOURCE_DIR}/config.h.in
281 ${PROJECT_BINARY_DIR}/config.h
282)
283
284#===============================================================================
285#= Sources
286#-------------------------------------------------------------------------------
287
288set(pulseview_SOURCES
289 main.cpp
290 pv/application.cpp
291 pv/devicemanager.cpp
292 pv/globalsettings.cpp
293 pv/logging.cpp
294 pv/mainwindow.cpp
295 pv/metadata_obj.cpp
296 pv/session.cpp
297 pv/storesession.cpp
298 pv/util.cpp
299 pv/binding/binding.cpp
300 pv/binding/inputoutput.cpp
301 pv/binding/device.cpp
302 pv/data/analog.cpp
303 pv/data/analogsegment.cpp
304 pv/data/logic.cpp
305 pv/data/logicsegment.cpp
306 pv/data/mathsignal.cpp
307 pv/data/signalbase.cpp
308 pv/data/signaldata.cpp
309 pv/data/segment.cpp
310 pv/devices/device.cpp
311 pv/devices/file.cpp
312 pv/devices/hardwaredevice.cpp
313 pv/devices/inputfile.cpp
314 pv/devices/sessionfile.cpp
315 pv/dialogs/connect.cpp
316 pv/dialogs/inputoutputoptions.cpp
317 pv/dialogs/settings.cpp
318 pv/dialogs/storeprogress.cpp
319 pv/popups/deviceoptions.cpp
320 pv/popups/channels.cpp
321 pv/prop/bool.cpp
322 pv/prop/double.cpp
323 pv/prop/enum.cpp
324 pv/prop/int.cpp
325 pv/prop/property.cpp
326 pv/prop/string.cpp
327 pv/subwindows/subwindowbase.cpp
328 pv/toolbars/mainbar.cpp
329 pv/views/trace/analogsignal.cpp
330 pv/views/trace/cursor.cpp
331 pv/views/trace/cursorpair.cpp
332 pv/views/trace/flag.cpp
333 pv/views/trace/header.cpp
334 pv/views/trace/mathsignal.cpp
335 pv/views/trace/marginwidget.cpp
336 pv/views/trace/logicsignal.cpp
337 pv/views/trace/ruler.cpp
338 pv/views/trace/signal.cpp
339 pv/views/trace/timeitem.cpp
340 pv/views/trace/timemarker.cpp
341 pv/views/trace/trace.cpp
342 pv/views/trace/tracegroup.cpp
343 pv/views/trace/tracepalette.cpp
344 pv/views/trace/tracetreeitem.cpp
345 pv/views/trace/tracetreeitemowner.cpp
346 pv/views/trace/triggermarker.cpp
347 pv/views/trace/view.cpp
348 pv/views/trace/viewitem.cpp
349 pv/views/trace/viewitemowner.cpp
350 pv/views/trace/viewitempaintparams.cpp
351 pv/views/trace/viewport.cpp
352 pv/views/trace/viewwidget.cpp
353 pv/views/viewbase.cpp
354 pv/views/trace/standardbar.cpp
355 pv/widgets/colorbutton.cpp
356 pv/widgets/colorpopup.cpp
357 pv/widgets/devicetoolbutton.cpp
358 pv/widgets/exportmenu.cpp
359 pv/widgets/flowlayout.cpp
360 pv/widgets/importmenu.cpp
361 pv/widgets/popup.cpp
362 pv/widgets/popuptoolbutton.cpp
363 pv/widgets/sweeptimingwidget.cpp
364 pv/widgets/timestampspinbox.cpp
365 pv/widgets/wellarray.cpp
366)
367
368# This list includes only QObject derived class headers.
369set(pulseview_HEADERS
370 pv/exprtk.hpp
371 pv/logging.hpp
372 pv/globalsettings.hpp
373 pv/mainwindow.hpp
374 pv/metadata_obj.hpp
375 pv/session.hpp
376 pv/storesession.hpp
377 pv/binding/device.hpp
378 pv/data/analog.hpp
379 pv/data/analogsegment.hpp
380 pv/data/logic.hpp
381 pv/data/logicsegment.hpp
382 pv/data/mathsignal.hpp
383 pv/data/signalbase.hpp
384 pv/dialogs/connect.hpp
385 pv/dialogs/inputoutputoptions.hpp
386 pv/dialogs/settings.hpp
387 pv/dialogs/storeprogress.hpp
388 pv/popups/channels.hpp
389 pv/popups/deviceoptions.hpp
390 pv/prop/bool.hpp
391 pv/prop/double.hpp
392 pv/prop/enum.hpp
393 pv/prop/int.hpp
394 pv/prop/property.hpp
395 pv/prop/string.hpp
396 pv/subwindows/subwindowbase.hpp
397 pv/toolbars/mainbar.hpp
398 pv/views/trace/analogsignal.hpp
399 pv/views/trace/cursor.hpp
400 pv/views/trace/flag.hpp
401 pv/views/trace/header.hpp
402 pv/views/trace/logicsignal.hpp
403 pv/views/trace/mathsignal.hpp
404 pv/views/trace/marginwidget.hpp
405 pv/views/trace/ruler.hpp
406 pv/views/trace/signal.hpp
407 pv/views/trace/timeitem.hpp
408 pv/views/trace/timemarker.hpp
409 pv/views/trace/trace.hpp
410 pv/views/trace/tracegroup.hpp
411 pv/views/trace/tracetreeitem.hpp
412 pv/views/trace/triggermarker.hpp
413 pv/views/trace/view.hpp
414 pv/views/trace/viewitem.hpp
415 pv/views/trace/viewport.hpp
416 pv/views/trace/viewwidget.hpp
417 pv/views/viewbase.hpp
418 pv/views/trace/standardbar.hpp
419 pv/widgets/colorbutton.hpp
420 pv/widgets/colorpopup.hpp
421 pv/widgets/devicetoolbutton.hpp
422 pv/widgets/exportmenu.hpp
423 pv/widgets/flowlayout.hpp
424 pv/widgets/importmenu.hpp
425 pv/widgets/popup.hpp
426 pv/widgets/popuptoolbutton.hpp
427 pv/widgets/sweeptimingwidget.hpp
428 pv/widgets/timestampspinbox.hpp
429 pv/widgets/wellarray.hpp
430)
431
432set(pulseview_RESOURCES
433 pulseview.qrc
434)
435
436if(ENABLE_SIGNALS)
437 list(APPEND pulseview_SOURCES signalhandler.cpp)
438 list(APPEND pulseview_HEADERS signalhandler.hpp)
439endif()
440
441if(ENABLE_DECODE)
442 list(APPEND pulseview_SOURCES
443 pv/binding/decoder.cpp
444 pv/data/decodesignal.cpp
445 pv/data/decode/annotation.cpp
446 pv/data/decode/decoder.cpp
447 pv/data/decode/row.cpp
448 pv/data/decode/rowdata.cpp
449 pv/subwindows/decoder_selector/item.cpp
450 pv/subwindows/decoder_selector/model.cpp
451 pv/subwindows/decoder_selector/subwindow.cpp
452 pv/views/decoder_binary/view.cpp
453 pv/views/decoder_binary/QHexView.cpp
454 pv/views/tabular_decoder/model.cpp
455 pv/views/tabular_decoder/view.cpp
456 pv/views/trace/decodetrace.cpp
457 pv/widgets/decodergroupbox.cpp
458 pv/widgets/decodermenu.cpp
459 )
460
461 list(APPEND pulseview_HEADERS
462 pv/data/decodesignal.hpp
463 pv/subwindows/decoder_selector/subwindow.hpp
464 pv/views/decoder_binary/view.hpp
465 pv/views/decoder_binary/QHexView.hpp
466 pv/views/tabular_decoder/view.hpp
467 pv/views/trace/decodetrace.hpp
468 pv/widgets/decodergroupbox.hpp
469 pv/widgets/decodermenu.hpp
470 )
471endif()
472
473if(WIN32)
474 # Use the sigrok icon for the pulseview.exe executable.
475 set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>")
476 enable_language(RC)
477 list(APPEND pulseview_SOURCES pulseviewico.rc)
478endif()
479
480if(ANDROID)
481 list(APPEND pulseview_SOURCES
482 android/assetreader.cpp
483 android/loghandler.cpp
484 )
485endif()
486
487qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
488
489#===============================================================================
490#= Translations
491#-------------------------------------------------------------------------------
492
493file(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/l10n/*.ts)
494set_property(SOURCE ${TS_FILES} PROPERTY OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/l10n)
495if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
496 configure_file("translations.qrc" "translations.qrc" COPYONLY)
497endif ()
498
499qt5_add_translation(QM_FILES ${TS_FILES})
500qt5_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES})
501
502qt5_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc)
503
504#===============================================================================
505#= Global Definitions
506#-------------------------------------------------------------------------------
507
508add_definitions(-DQT_NO_KEYWORDS)
509add_definitions(-D__STDC_LIMIT_MACROS)
510add_definitions(-Wall -Wextra)
511
512# The OSX 12 Monteray stdlib requires C++17 to compile.
513if(APPLE AND PV_HAVE_C++17)
514 add_definitions(-std=c++17)
515else()
516 add_definitions(-std=c++11)
517endif()
518
519add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1)
520if(WIN32)
521 add_definitions(-Wa,-mbig-obj -O3)
522endif()
523
524if(ENABLE_FLOW)
525 add_definitions(-DENABLE_FLOW)
526endif()
527
528if(ENABLE_DECODE)
529 add_definitions(-DENABLE_DECODE)
530endif()
531
532if(NOT DISABLE_WERROR)
533 add_definitions(-Werror)
534endif()
535
536if(ENABLE_SIGNALS)
537 add_definitions(-DENABLE_SIGNALS)
538endif()
539
540if(ENABLE_STACKTRACE)
541 add_definitions(-DENABLE_STACKTRACE -no-pie -fno-pie)
542 if (Backtrace_FOUND)
543 add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE)
544 endif()
545endif()
546
547#===============================================================================
548#= Global Include Directories
549#-------------------------------------------------------------------------------
550
551include_directories(
552 ${CMAKE_CURRENT_BINARY_DIR}
553 ${CMAKE_CURRENT_SOURCE_DIR}
554 ${Boost_INCLUDE_DIRS}
555)
556
557if(STATIC_PKGDEPS_LIBS)
558 include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS})
559else()
560 include_directories(${PKGDEPS_INCLUDE_DIRS})
561endif()
562
563#===============================================================================
564#= Linker Configuration
565#-------------------------------------------------------------------------------
566
567link_directories(${Boost_LIBRARY_DIRS})
568
569set(PULSEVIEW_LINK_LIBS
570 ${Boost_LIBRARIES}
571 ${QT_LIBRARIES}
572 ${CMAKE_THREAD_LIBS_INIT}
573 ${LIBATOMIC_LIBRARY}
574)
575
576if(STATIC_PKGDEPS_LIBS)
577 link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
578 list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LDFLAGS})
579else()
580 link_directories(${PKGDEPS_LIBRARY_DIRS})
581 list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
582endif()
583
584if(WIN32)
585 # On Windows we need to statically link the libqsvg imageformat
586 # plugin (and the QtSvg component) for SVG graphics/icons to work.
587 # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport (only for
588 # Qt < 5.8.0), and all Qt libs and their dependencies.
589 add_definitions(-DQT_STATICPLUGIN)
590 list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
591 list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
592 if(Qt5Gui_VERSION VERSION_LESS 5.8.0)
593 list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport)
594 endif()
595 list(APPEND PULSEVIEW_LINK_LIBS ${QT5ALL_LDFLAGS})
596endif()
597
598if(ENABLE_STACKTRACE)
599 list(APPEND PULSEVIEW_LINK_LIBS ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
600 link_libraries("-no-pie -fno-pie")
601endif()
602
603if(ANDROID)
604 list(APPEND PULSEVIEW_LINK_LIBS "-llog")
605endif()
606
607set(INPUT_FILES_LIST ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC} ${QM_FILES})
608if(ANDROID)
609 add_library(${PROJECT_NAME} SHARED ${INPUT_FILES_LIST})
610else()
611 add_executable(${PROJECT_NAME} ${INPUT_FILES_LIST})
612endif()
613
614target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})
615
616if(WIN32 AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
617 # Pass -mwindows so that no "DOS box" opens when PulseView is started.
618 set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows")
619endif()
620
621#===============================================================================
622#= Installation
623#-------------------------------------------------------------------------------
624
625# Install the executable.
626install(TARGETS ${PROJECT_NAME} DESTINATION bin/)
627
628# Install the manpage.
629install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
630
631# Install the desktop file.
632install(FILES contrib/org.sigrok.PulseView.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
633
634# Install the AppData/AppStream file.
635install(FILES contrib/org.sigrok.PulseView.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
636
637# Install the PulseView icons.
638install(FILES icons/pulseview.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps)
639install(FILES icons/pulseview.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
640
641# Generate Windows installer script.
642configure_file(contrib/pulseview_cross.nsi.in ${CMAKE_CURRENT_BINARY_DIR}/contrib/pulseview_cross.nsi @ONLY)
643
644#===============================================================================
645#= Packaging (handled by CPack)
646#-------------------------------------------------------------------------------
647
648set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR})
649set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR})
650set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO})
651set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
652set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
653set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git")
654set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PV_VERSION_STRING}")
655set(CPACK_SOURCE_GENERATOR "TGZ")
656
657include(CPack)
658
659#===============================================================================
660#= Tests
661#-------------------------------------------------------------------------------
662
663if(ENABLE_TESTS)
664 add_subdirectory(test)
665 enable_testing()
666 add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test)
667endif()