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