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