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