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