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