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