]>
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 | ||
7ba41e7e | 21 | cmake_minimum_required(VERSION 2.8.6) |
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) |
9e8e84fc | 38 | option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE) |
b04e278d AG |
39 | |
40 | if(WIN32) | |
7d297a01 UH |
41 | # On Windows/MinGW we need to statically link to libraries. |
42 | # This option is user configurable, but enable it by default on win32. | |
b04e278d | 43 | set(STATIC_PKGDEPS_LIBS TRUE) |
6987ceeb | 44 | |
2a21747e UH |
45 | # For boost-thread we need two additional settings on win32: |
46 | set(Boost_USE_STATIC_LIBS ON) | |
47 | add_definitions(-DBOOST_THREAD_USE_LIB) | |
48 | ||
e6fd809f UH |
49 | # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'. |
50 | # The library is named libboost_thread_win32* (not libboost_thread*). | |
51 | set(Boost_THREADAPI win32) | |
52 | ||
0aad432c | 53 | # Windows does not support UNIX signals. |
140181a4 | 54 | set(ENABLE_SIGNALS FALSE) |
b04e278d | 55 | endif() |
506523c1 | 56 | |
552f686e | 57 | if(NOT CMAKE_BUILD_TYPE) |
7591fe23 UH |
58 | set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING |
59 | "Choose the type of build (None, Debug, Release, RelWithDebInfo, MinSizeRel)." | |
60 | FORCE) | |
552f686e JH |
61 | endif() |
62 | ||
506523c1 | 63 | #=============================================================================== |
30588653 AG |
64 | #= Dependencies |
65 | #------------------------------------------------------------------------------- | |
66 | ||
68ef4b9d | 67 | list(APPEND PKGDEPS libsigrokcxx>=0.4.0) |
df944399 | 68 | |
269528f5 | 69 | if(ENABLE_DECODE) |
68ef4b9d | 70 | list(APPEND PKGDEPS libsigrokdecode>=0.4.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 | ||
9e8e84fc MC |
80 | if(FORCE_QT4) |
81 | set(Qt5Core_FOUND FALSE) | |
82 | else() | |
83 | find_package(Qt5Core QUIET) | |
09f55d96 UH |
84 | if(WIN32) |
85 | # MXE workaround: Use pkg-config to find Qt5 libs. | |
86 | # https://github.com/mxe/mxe/issues/1642 | |
87 | pkg_check_modules(QT5ALL REQUIRED Qt5Widgets Qt5Gui Qt5Svg) | |
88 | endif() | |
9e8e84fc MC |
89 | endif() |
90 | ||
91 | if(Qt5Core_FOUND) | |
92 | message("-- Using Qt5") | |
93 | find_package(Qt5Widgets REQUIRED) | |
94 | find_package(Qt5Gui REQUIRED) | |
726ea667 | 95 | find_package(Qt5Svg REQUIRED) |
1cd4be22 | 96 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") |
ea370bc6 | 97 | set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) |
726ea667 | 98 | set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg) |
9e8e84fc MC |
99 | add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) |
100 | else() | |
101 | find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) | |
52f38de6 | 102 | find_package(Qt4 REQUIRED QtCore QtGui QtSvg) |
9e8e84fc | 103 | endif() |
2e2946fe | 104 | |
d68d75c2 | 105 | set(BOOSTCOMPS filesystem serialization system thread) |
226a1527 | 106 | if(ENABLE_TESTS) |
d68d75c2 | 107 | list(APPEND BOOSTCOMPS unit_test_framework) |
2a21747e | 108 | endif() |
d68d75c2 | 109 | find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED) |
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 | |
116 | # Check for explicit link against libatomic | |
117 | # | |
118 | # Depending on the toolchain, linking a program using atomic functions may need | |
119 | # "-latomic" explicitly passed to the linker | |
120 | # | |
121 | # This check first tests if atomics are available in the C-library, if not and | |
122 | # libatomic exists, then it runs the same test with -latomic added to the | |
123 | # linker flags. | |
124 | ||
125 | # Helper for checking for atomics | |
126 | function(check_working_cxx_atomics varname additional_lib) | |
127 | include(CheckCXXSourceCompiles) | |
128 | include(CMakePushCheckState) | |
129 | cmake_push_check_state() | |
130 | set(CMAKE_REQUIRED_FLAGS "-std=c++11") | |
131 | set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}") | |
132 | set(CMAKE_REQUIRED_QUIET 1) | |
133 | CHECK_CXX_SOURCE_COMPILES(" | |
134 | #include <atomic> | |
135 | std::atomic<int> x; | |
136 | int main() { | |
137 | return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst); | |
138 | } | |
139 | " ${varname}) | |
140 | cmake_pop_check_state() | |
141 | endfunction(check_working_cxx_atomics) | |
142 | ||
143 | # First check if atomics work without the library. | |
144 | # If not, check if the library exists, and atomics work with it. | |
145 | check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB "") | |
146 | if(HAVE_CXX_ATOMICS_WITHOUT_LIB) | |
147 | message(STATUS "Atomics provided by the C-library - yes") | |
148 | else() | |
149 | message(STATUS "Atomics provided by the C-library - no") | |
150 | find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib) | |
151 | if(LIBATOMIC_LIBRARY) | |
152 | check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}") | |
153 | if (HAVE_CXX_ATOMICS_WITH_LIB) | |
154 | message(STATUS "Atomics provided by libatomic - yes") | |
155 | else() | |
156 | message(STATUS "Atomics provided by libatomic - no") | |
157 | message(FATAL_ERROR "Compiler must support std::atomic!") | |
158 | endif() | |
159 | else() | |
160 | message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.") | |
161 | endif() | |
162 | endif() | |
163 | ||
9df8453f MC |
164 | #=============================================================================== |
165 | #= System Introspection | |
166 | #------------------------------------------------------------------------------- | |
167 | ||
168 | include(memaccess) | |
169 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
170 | ||
075fb499 AG |
171 | #=============================================================================== |
172 | #= Config Header | |
173 | #------------------------------------------------------------------------------- | |
174 | ||
f7951df4 | 175 | set(PV_TITLE PulseView) |
d4384c6d | 176 | set(PV_DESCRIPTION "A GUI for sigrok") |
4a9e84ca | 177 | set(PV_VERSION_STRING "0.4.0") |
f7951df4 | 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 |
51e77110 | 214 | pv/mainwindow.cpp |
f65cd27b | 215 | pv/session.cpp |
0fbda3c2 | 216 | pv/storesession.cpp |
f0c9f81c | 217 | pv/util.cpp |
61703a01 | 218 | pv/binding/binding.cpp |
0c913637 | 219 | pv/binding/inputoutput.cpp |
3cc9ad7b | 220 | pv/binding/device.cpp |
1b1ec774 | 221 | pv/data/analog.cpp |
f3d66e52 | 222 | pv/data/analogsegment.cpp |
1b1ec774 | 223 | pv/data/logic.cpp |
f3d66e52 | 224 | pv/data/logicsegment.cpp |
bf0edd2b | 225 | pv/data/signalbase.cpp |
1b1ec774 | 226 | pv/data/signaldata.cpp |
f3d66e52 | 227 | pv/data/segment.cpp |
da30ecb7 | 228 | pv/devices/device.cpp |
474e817a | 229 | pv/devices/file.cpp |
da30ecb7 | 230 | pv/devices/hardwaredevice.cpp |
5237f0c5 | 231 | pv/devices/inputfile.cpp |
da30ecb7 | 232 | pv/devices/sessionfile.cpp |
9663c82b | 233 | pv/dialogs/connect.cpp |
e93f5538 | 234 | pv/dialogs/inputoutputoptions.cpp |
bf9f1268 | 235 | pv/dialogs/settings.cpp |
0fbda3c2 | 236 | pv/dialogs/storeprogress.cpp |
51d4a9ab | 237 | pv/popups/deviceoptions.cpp |
6ac6242b | 238 | pv/popups/channels.cpp |
de1d99bb | 239 | pv/prop/bool.cpp |
b912c99c | 240 | pv/prop/double.cpp |
820c3dea | 241 | pv/prop/enum.cpp |
a2b92157 | 242 | pv/prop/int.cpp |
c8df6005 | 243 | pv/prop/property.cpp |
7112a458 | 244 | pv/prop/string.cpp |
7c657094 | 245 | pv/toolbars/mainbar.cpp |
aba1dd16 | 246 | pv/view/analogsignal.cpp |
cabce982 | 247 | pv/view/cursor.cpp |
b42d25c4 | 248 | pv/view/cursorpair.cpp |
8914fe79 | 249 | pv/view/flag.cpp |
1d8dca91 | 250 | pv/view/header.cpp |
c23b29d6 | 251 | pv/view/marginwidget.cpp |
8d634081 | 252 | pv/view/logicsignal.cpp |
7c8b6ad2 | 253 | pv/view/rowitem.cpp |
ccdd3ef5 | 254 | pv/view/ruler.cpp |
8d634081 | 255 | pv/view/signal.cpp |
f1626bb8 | 256 | pv/view/signalscalehandle.cpp |
ad341c3a | 257 | pv/view/timeitem.cpp |
cd6c8ee2 | 258 | pv/view/timemarker.cpp |
931f20b0 | 259 | pv/view/trace.cpp |
722930c1 | 260 | pv/view/tracegroup.cpp |
91e8bf08 | 261 | pv/view/tracepalette.cpp |
af503b10 JH |
262 | pv/view/tracetreeitem.cpp |
263 | pv/view/tracetreeitemowner.cpp | |
51ae69ae | 264 | pv/view/triggermarker.cpp |
cdf7bea7 | 265 | pv/view/view.cpp |
26e3af6b | 266 | pv/view/viewitem.cpp |
c373f828 | 267 | pv/view/viewitemowner.cpp |
5b5fa4da | 268 | pv/view/viewitempaintparams.cpp |
cdf7bea7 | 269 | pv/view/viewport.cpp |
40aca27e | 270 | pv/view/viewwidget.cpp |
f4e57597 | 271 | pv/views/viewbase.cpp |
e0ba4f6f | 272 | pv/views/trace/standardbar.cpp |
91e8bf08 JH |
273 | pv/widgets/colourbutton.cpp |
274 | pv/widgets/colourpopup.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 |
bf9f1268 | 287 | pv/globalsettings.hpp |
2acdb232 | 288 | pv/mainwindow.hpp |
f65cd27b | 289 | pv/session.hpp |
2acdb232 | 290 | pv/storesession.hpp |
3cc9ad7b | 291 | pv/binding/device.hpp |
7db61e77 SA |
292 | pv/data/analog.hpp |
293 | pv/data/analogsegment.hpp | |
294 | pv/data/logic.hpp | |
295 | pv/data/logicsegment.hpp | |
bf0edd2b | 296 | pv/data/signalbase.hpp |
2acdb232 | 297 | pv/dialogs/connect.hpp |
e93f5538 | 298 | pv/dialogs/inputoutputoptions.hpp |
bf9f1268 | 299 | pv/dialogs/settings.hpp |
2acdb232 JH |
300 | pv/dialogs/storeprogress.hpp |
301 | pv/popups/channels.hpp | |
302 | pv/popups/deviceoptions.hpp | |
303 | pv/prop/bool.hpp | |
304 | pv/prop/double.hpp | |
305 | pv/prop/enum.hpp | |
306 | pv/prop/int.hpp | |
307 | pv/prop/property.hpp | |
308 | pv/prop/string.hpp | |
7c657094 | 309 | pv/toolbars/mainbar.hpp |
4cffac16 | 310 | pv/view/analogsignal.hpp |
2acdb232 | 311 | pv/view/cursor.hpp |
8914fe79 | 312 | pv/view/flag.hpp |
2acdb232 JH |
313 | pv/view/header.hpp |
314 | pv/view/logicsignal.hpp | |
315 | pv/view/marginwidget.hpp | |
316 | pv/view/rowitem.hpp | |
317 | pv/view/ruler.hpp | |
2acdb232 | 318 | pv/view/signal.hpp |
f1626bb8 | 319 | pv/view/signalscalehandle.hpp |
ad341c3a | 320 | pv/view/timeitem.hpp |
2acdb232 JH |
321 | pv/view/timemarker.hpp |
322 | pv/view/trace.hpp | |
323 | pv/view/tracegroup.hpp | |
af503b10 | 324 | pv/view/tracetreeitem.hpp |
51ae69ae | 325 | pv/view/triggermarker.hpp |
2acdb232 | 326 | pv/view/view.hpp |
26e3af6b | 327 | pv/view/viewitem.hpp |
2acdb232 | 328 | pv/view/viewport.hpp |
40aca27e | 329 | pv/view/viewwidget.hpp |
f4e57597 | 330 | pv/views/viewbase.hpp |
e0ba4f6f | 331 | pv/views/trace/standardbar.hpp |
2acdb232 JH |
332 | pv/widgets/colourbutton.hpp |
333 | pv/widgets/colourpopup.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 | ||
a8d3fb2d JH |
344 | set(pulseview_RESOURCES |
345 | pulseview.qrc | |
df944399 JH |
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 |
269528f5 JH |
356 | pv/data/decoderstack.cpp |
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 | |
269528f5 JH |
361 | pv/view/decodetrace.cpp |
362 | pv/widgets/decodergroupbox.cpp | |
363 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
364 | ) |
365 | ||
366 | list(APPEND pulseview_HEADERS | |
2acdb232 JH |
367 | pv/data/decoderstack.hpp |
368 | pv/view/decodetrace.hpp | |
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 | ||
9e8e84fc MC |
388 | if(Qt5Core_FOUND) |
389 | qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
9e8e84fc MC |
390 | qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) |
391 | else() | |
39ccf9c3 | 392 | # Workaround for QTBUG-22829: -DBOOST_NEXT_PRIOR_HPP_INCLUDED. |
0661570b UH |
393 | # https://bugreports.qt.io/browse/QTBUG-22829 |
394 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS} | |
395 | OPTIONS -DBOOST_NEXT_PRIOR_HPP_INCLUDED) | |
9e8e84fc MC |
396 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) |
397 | include(${QT_USE_FILE}) | |
398 | endif() | |
df944399 | 399 | |
30588653 AG |
400 | #=============================================================================== |
401 | #= Global Definitions | |
402 | #------------------------------------------------------------------------------- | |
403 | ||
e9213170 | 404 | add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS) |
ac223c1e | 405 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 406 | add_definitions(-Wall -Wextra) |
95d43108 | 407 | add_definitions(-std=c++11) |
a838ed7b | 408 | add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1) |
5f606159 | 409 | |
269528f5 JH |
410 | if(ENABLE_DECODE) |
411 | add_definitions(-DENABLE_DECODE) | |
412 | endif() | |
413 | ||
5f606159 JH |
414 | if(NOT DISABLE_WERROR) |
415 | add_definitions(-Werror) | |
416 | endif() | |
df944399 | 417 | |
9632990d UH |
418 | if(ENABLE_SIGNALS) |
419 | add_definitions(-DENABLE_SIGNALS) | |
420 | endif() | |
421 | ||
30588653 AG |
422 | #=============================================================================== |
423 | #= Global Include Directories | |
424 | #------------------------------------------------------------------------------- | |
425 | ||
b04e278d AG |
426 | include_directories( |
427 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 428 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d | 429 | ${Boost_INCLUDE_DIRS} |
9e8e84fc | 430 | ${QT_INCLUDE_DIRS} |
b04e278d AG |
431 | ) |
432 | ||
433 | if(STATIC_PKGDEPS_LIBS) | |
434 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
435 | else() | |
436 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
437 | endif() | |
df944399 | 438 | |
30588653 AG |
439 | #=============================================================================== |
440 | #= Linker Configuration | |
441 | #------------------------------------------------------------------------------- | |
442 | ||
b04e278d AG |
443 | link_directories(${Boost_LIBRARY_DIRS}) |
444 | ||
445 | set(PULSEVIEW_LINK_LIBS | |
446 | ${Boost_LIBRARIES} | |
447 | ${QT_LIBRARIES} | |
2b76309a | 448 | ${CMAKE_THREAD_LIBS_INIT} |
4da54b6b | 449 | ${LIBATOMIC_LIBRARY} |
b04e278d AG |
450 | ) |
451 | ||
452 | if(STATIC_PKGDEPS_LIBS) | |
cddf172d | 453 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) |
09f55d96 | 454 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LDFLAGS}) |
b04e278d | 455 | else() |
cddf172d UH |
456 | link_directories(${PKGDEPS_LIBRARY_DIRS}) |
457 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
b04e278d | 458 | endif() |
df944399 | 459 | |
11a04e2a UH |
460 | if(WIN32) |
461 | # On Windows we need to statically link the libqsvg imageformat | |
462 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
09f55d96 UH |
463 | # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport, and all |
464 | # Qt libs and their dependencies. | |
11a04e2a | 465 | add_definitions(-DQT_STATICPLUGIN) |
09f55d96 UH |
466 | list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin) |
467 | list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin) | |
468 | list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport ${QT5ALL_LDFLAGS}) | |
11a04e2a UH |
469 | endif() |
470 | ||
9137928c MC |
471 | if(ANDROID) |
472 | list(APPEND PULSEVIEW_LINK_LIBS "-llog") | |
473 | endif() | |
474 | ||
26807061 MC |
475 | if(ANDROID) |
476 | add_library(${PROJECT_NAME} SHARED | |
477 | ${pulseview_SOURCES} | |
478 | ${pulseview_HEADERS_MOC} | |
26807061 MC |
479 | ${pulseview_RESOURCES_RCC} |
480 | ) | |
481 | else() | |
5a13850b | 482 | add_executable(${PROJECT_NAME} |
a8d3fb2d JH |
483 | ${pulseview_SOURCES} |
484 | ${pulseview_HEADERS_MOC} | |
a8d3fb2d | 485 | ${pulseview_RESOURCES_RCC} |
df944399 | 486 | ) |
26807061 | 487 | endif() |
df944399 | 488 | |
5a13850b | 489 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 490 | |
b0d8c0dc | 491 | if(WIN32) |
61e1e13e UH |
492 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
493 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
494 | endif() |
495 | ||
30588653 AG |
496 | #=============================================================================== |
497 | #= Installation | |
498 | #------------------------------------------------------------------------------- | |
499 | ||
52bbe600 | 500 | # Install the executable. |
cd6606c2 AG |
501 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
502 | ||
52bbe600 UH |
503 | # Install the manpage. |
504 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
505 | ||
f9cb49cc DE |
506 | # Generate Windows installer script. |
507 | configure_file(contrib/pulseview_cross.nsi.in contrib/pulseview_cross.nsi @ONLY) | |
508 | ||
cd6606c2 AG |
509 | #=============================================================================== |
510 | #= Packaging (handled by CPack) | |
511 | #------------------------------------------------------------------------------- | |
512 | ||
b02a8cbf JH |
513 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
514 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
515 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
516 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
517 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
518 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
1e8c82e9 | 519 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PV_VERSION_STRING}") |
1d2fb87d | 520 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
521 | |
522 | include(CPack) | |
bc1c1462 | 523 | |
30588653 AG |
524 | #=============================================================================== |
525 | #= Tests | |
526 | #------------------------------------------------------------------------------- | |
527 | ||
77e8ac52 | 528 | if(ENABLE_TESTS) |
fb746bcc | 529 | add_subdirectory(test) |
951c583c | 530 | enable_testing() |
fb746bcc | 531 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 532 | endif() |