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