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