]>
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 | |
df944399 | 23 | include(FindPkgConfig) |
52bbe600 | 24 | include(GNUInstallDirs) |
df944399 | 25 | |
a8d3fb2d | 26 | project(pulseview) |
df944399 | 27 | |
cf2b5b64 UH |
28 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") |
29 | ||
30588653 | 30 | #=============================================================================== |
506523c1 JH |
31 | #= User Options |
32 | #------------------------------------------------------------------------------- | |
33 | ||
5f606159 | 34 | option(DISABLE_WERROR "Build without -Werror" FALSE) |
140181a4 | 35 | option(ENABLE_SIGNALS "Build with UNIX signals" TRUE) |
19f511a4 | 36 | option(ENABLE_DECODE "Build with libsigrokdecode" TRUE) |
506523c1 | 37 | option(ENABLE_TESTS "Enable unit tests" FALSE) |
61e1e13e | 38 | option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE) |
9e8e84fc | 39 | option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE) |
b04e278d AG |
40 | |
41 | if(WIN32) | |
7d297a01 UH |
42 | # On Windows/MinGW we need to statically link to libraries. |
43 | # This option is user configurable, but enable it by default on win32. | |
b04e278d | 44 | set(STATIC_PKGDEPS_LIBS TRUE) |
6987ceeb | 45 | |
2a21747e UH |
46 | # For boost-thread we need two additional settings on win32: |
47 | set(Boost_USE_STATIC_LIBS ON) | |
48 | add_definitions(-DBOOST_THREAD_USE_LIB) | |
49 | ||
e6fd809f UH |
50 | # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'. |
51 | # The library is named libboost_thread_win32* (not libboost_thread*). | |
52 | set(Boost_THREADAPI win32) | |
53 | ||
0aad432c | 54 | # Windows does not support UNIX signals. |
140181a4 | 55 | set(ENABLE_SIGNALS FALSE) |
b04e278d | 56 | endif() |
506523c1 | 57 | |
552f686e | 58 | if(NOT CMAKE_BUILD_TYPE) |
7591fe23 UH |
59 | set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING |
60 | "Choose the type of build (None, Debug, Release, RelWithDebInfo, MinSizeRel)." | |
61 | FORCE) | |
552f686e JH |
62 | endif() |
63 | ||
506523c1 | 64 | #=============================================================================== |
30588653 AG |
65 | #= Dependencies |
66 | #------------------------------------------------------------------------------- | |
67 | ||
e8d00928 | 68 | list(APPEND PKGDEPS libsigrokxx>=0.3.0) |
df944399 | 69 | |
269528f5 | 70 | if(ENABLE_DECODE) |
ab186d22 | 71 | list(APPEND PKGDEPS libsigrokdecode>=0.3.0) |
269528f5 JH |
72 | endif() |
73 | ||
aff51746 MC |
74 | if(ANDROID) |
75 | list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) | |
76 | endif() | |
77 | ||
d52d8455 JH |
78 | find_package(PkgConfig) |
79 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) | |
80 | ||
9e8e84fc MC |
81 | if(FORCE_QT4) |
82 | set(Qt5Core_FOUND FALSE) | |
83 | else() | |
84 | find_package(Qt5Core QUIET) | |
85 | endif() | |
86 | ||
87 | if(Qt5Core_FOUND) | |
88 | message("-- Using Qt5") | |
89 | find_package(Qt5Widgets REQUIRED) | |
90 | find_package(Qt5Gui REQUIRED) | |
726ea667 | 91 | find_package(Qt5Svg REQUIRED) |
1cd4be22 | 92 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") |
ea370bc6 | 93 | set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) |
726ea667 | 94 | set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg) |
9e8e84fc MC |
95 | add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) |
96 | else() | |
97 | find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) | |
52f38de6 | 98 | find_package(Qt4 REQUIRED QtCore QtGui QtSvg) |
9e8e84fc | 99 | endif() |
2e2946fe | 100 | |
226a1527 UH |
101 | if(ENABLE_TESTS) |
102 | find_package(Boost 1.42 COMPONENTS filesystem system thread unit_test_framework REQUIRED) | |
2a21747e UH |
103 | else() |
104 | find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED) | |
105 | endif() | |
df944399 | 106 | |
858ae630 UH |
107 | # Find the platform's thread library (needed for C++11 threads). |
108 | # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. | |
2b76309a AJ |
109 | find_package(Threads REQUIRED) |
110 | ||
9df8453f MC |
111 | #=============================================================================== |
112 | #= System Introspection | |
113 | #------------------------------------------------------------------------------- | |
114 | ||
115 | include(memaccess) | |
116 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
117 | ||
075fb499 AG |
118 | #=============================================================================== |
119 | #= Config Header | |
120 | #------------------------------------------------------------------------------- | |
121 | ||
f7951df4 | 122 | set(PV_TITLE PulseView) |
d4384c6d | 123 | set(PV_DESCRIPTION "A GUI for sigrok") |
f7951df4 | 124 | |
075fb499 | 125 | set(PV_VERSION_MAJOR 0) |
744905d4 | 126 | set(PV_VERSION_MINOR 2) |
075fb499 AG |
127 | set(PV_VERSION_MICRO 0) |
128 | set(PV_VERSION_STRING | |
129 | ${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO} | |
130 | ) | |
131 | ||
132 | configure_file ( | |
133 | ${PROJECT_SOURCE_DIR}/config.h.in | |
134 | ${PROJECT_BINARY_DIR}/config.h | |
135 | ) | |
df944399 | 136 | |
30588653 AG |
137 | #=============================================================================== |
138 | #= Sources | |
139 | #------------------------------------------------------------------------------- | |
140 | ||
a8d3fb2d | 141 | set(pulseview_SOURCES |
df944399 | 142 | main.cpp |
dac1bb97 | 143 | pv/application.cpp |
107ca6d3 | 144 | pv/devicemanager.cpp |
51e77110 | 145 | pv/mainwindow.cpp |
f65cd27b | 146 | pv/session.cpp |
0fbda3c2 | 147 | pv/storesession.cpp |
f0c9f81c | 148 | pv/util.cpp |
1b1ec774 | 149 | pv/data/analog.cpp |
f3d66e52 | 150 | pv/data/analogsegment.cpp |
1b1ec774 | 151 | pv/data/logic.cpp |
f3d66e52 | 152 | pv/data/logicsegment.cpp |
1b1ec774 | 153 | pv/data/signaldata.cpp |
f3d66e52 | 154 | pv/data/segment.cpp |
acda14b8 | 155 | pv/dialogs/about.cpp |
9663c82b | 156 | pv/dialogs/connect.cpp |
0fbda3c2 | 157 | pv/dialogs/storeprogress.cpp |
51d4a9ab | 158 | pv/popups/deviceoptions.cpp |
6ac6242b | 159 | pv/popups/channels.cpp |
de1d99bb | 160 | pv/prop/bool.cpp |
b912c99c | 161 | pv/prop/double.cpp |
820c3dea | 162 | pv/prop/enum.cpp |
a2b92157 | 163 | pv/prop/int.cpp |
c8df6005 | 164 | pv/prop/property.cpp |
7112a458 | 165 | pv/prop/string.cpp |
c8df6005 | 166 | pv/prop/binding/binding.cpp |
3820592a | 167 | pv/prop/binding/deviceoptions.cpp |
f4c92e1c | 168 | pv/toolbars/samplingbar.cpp |
aba1dd16 | 169 | pv/view/analogsignal.cpp |
cabce982 | 170 | pv/view/cursor.cpp |
84a0d458 | 171 | pv/view/cursorheader.cpp |
b42d25c4 | 172 | pv/view/cursorpair.cpp |
1d8dca91 | 173 | pv/view/header.cpp |
c23b29d6 | 174 | pv/view/marginwidget.cpp |
8d634081 | 175 | pv/view/logicsignal.cpp |
23935421 | 176 | pv/view/rowitem.cpp |
18f7104f | 177 | pv/view/rowitemowner.cpp |
3eb29afd | 178 | pv/view/rowitempaintparams.cpp |
ccdd3ef5 | 179 | pv/view/ruler.cpp |
f1283456 | 180 | pv/view/selectableitem.cpp |
8d634081 | 181 | pv/view/signal.cpp |
cd6c8ee2 | 182 | pv/view/timemarker.cpp |
931f20b0 | 183 | pv/view/trace.cpp |
722930c1 | 184 | pv/view/tracegroup.cpp |
91e8bf08 | 185 | pv/view/tracepalette.cpp |
cdf7bea7 JH |
186 | pv/view/view.cpp |
187 | pv/view/viewport.cpp | |
91e8bf08 JH |
188 | pv/widgets/colourbutton.cpp |
189 | pv/widgets/colourpopup.cpp | |
6e3f046e | 190 | pv/widgets/popup.cpp |
6a91973f | 191 | pv/widgets/popuptoolbutton.cpp |
1198b887 | 192 | pv/widgets/sweeptimingwidget.cpp |
0c0e1888 | 193 | pv/widgets/wellarray.cpp |
df944399 JH |
194 | ) |
195 | ||
0aad432c | 196 | # This list includes only QObject derived class headers. |
a8d3fb2d | 197 | set(pulseview_HEADERS |
2acdb232 | 198 | pv/mainwindow.hpp |
f65cd27b | 199 | pv/session.hpp |
2acdb232 JH |
200 | pv/storesession.hpp |
201 | pv/dialogs/about.hpp | |
202 | pv/dialogs/connect.hpp | |
203 | pv/dialogs/storeprogress.hpp | |
204 | pv/popups/channels.hpp | |
205 | pv/popups/deviceoptions.hpp | |
206 | pv/prop/bool.hpp | |
207 | pv/prop/double.hpp | |
208 | pv/prop/enum.hpp | |
209 | pv/prop/int.hpp | |
210 | pv/prop/property.hpp | |
211 | pv/prop/string.hpp | |
212 | pv/prop/binding/deviceoptions.hpp | |
213 | pv/toolbars/samplingbar.hpp | |
214 | pv/view/cursor.hpp | |
215 | pv/view/cursorheader.hpp | |
216 | pv/view/header.hpp | |
217 | pv/view/logicsignal.hpp | |
218 | pv/view/marginwidget.hpp | |
219 | pv/view/rowitem.hpp | |
220 | pv/view/ruler.hpp | |
221 | pv/view/selectableitem.hpp | |
222 | pv/view/signal.hpp | |
223 | pv/view/timemarker.hpp | |
224 | pv/view/trace.hpp | |
225 | pv/view/tracegroup.hpp | |
226 | pv/view/view.hpp | |
227 | pv/view/viewport.hpp | |
228 | pv/widgets/colourbutton.hpp | |
229 | pv/widgets/colourpopup.hpp | |
230 | pv/widgets/popup.hpp | |
231 | pv/widgets/popuptoolbutton.hpp | |
232 | pv/widgets/sweeptimingwidget.hpp | |
233 | pv/widgets/wellarray.hpp | |
df944399 JH |
234 | ) |
235 | ||
a8d3fb2d | 236 | set(pulseview_FORMS |
acda14b8 | 237 | pv/dialogs/about.ui |
df944399 JH |
238 | ) |
239 | ||
a8d3fb2d JH |
240 | set(pulseview_RESOURCES |
241 | pulseview.qrc | |
df944399 JH |
242 | ) |
243 | ||
140181a4 JH |
244 | if(ENABLE_SIGNALS) |
245 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
2acdb232 | 246 | list(APPEND pulseview_HEADERS signalhandler.hpp) |
140181a4 JH |
247 | endif() |
248 | ||
269528f5 JH |
249 | if(ENABLE_DECODE) |
250 | list(APPEND pulseview_SOURCES | |
251 | pv/data/decoderstack.cpp | |
252 | pv/data/decode/annotation.cpp | |
253 | pv/data/decode/decoder.cpp | |
f9101a91 JH |
254 | pv/data/decode/row.cpp |
255 | pv/data/decode/rowdata.cpp | |
269528f5 JH |
256 | pv/prop/binding/decoderoptions.cpp |
257 | pv/view/decodetrace.cpp | |
258 | pv/widgets/decodergroupbox.cpp | |
259 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
260 | ) |
261 | ||
262 | list(APPEND pulseview_HEADERS | |
2acdb232 JH |
263 | pv/data/decoderstack.hpp |
264 | pv/view/decodetrace.hpp | |
265 | pv/widgets/decodergroupbox.hpp | |
266 | pv/widgets/decodermenu.hpp | |
269528f5 JH |
267 | ) |
268 | endif() | |
269 | ||
fe15e0bc UH |
270 | if(WIN32) |
271 | # Use the sigrok icon for the pulseview.exe executable. | |
272 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
273 | enable_language(RC) | |
61e1e13e | 274 | list(APPEND pulseview_SOURCES pulseviewico.rc) |
fe15e0bc UH |
275 | endif() |
276 | ||
9137928c MC |
277 | if(ANDROID) |
278 | list(APPEND pulseview_SOURCES android/loghandler.cpp) | |
279 | endif() | |
280 | ||
9e8e84fc MC |
281 | if(Qt5Core_FOUND) |
282 | qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
283 | qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
284 | qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
285 | else() | |
286 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
287 | qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
288 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
289 | include(${QT_USE_FILE}) | |
290 | endif() | |
df944399 | 291 | |
30588653 AG |
292 | #=============================================================================== |
293 | #= Global Definitions | |
294 | #------------------------------------------------------------------------------- | |
295 | ||
e9213170 | 296 | add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS) |
ac223c1e | 297 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 298 | add_definitions(-Wall -Wextra) |
95d43108 | 299 | add_definitions(-std=c++11) |
5f606159 | 300 | |
269528f5 JH |
301 | if(ENABLE_DECODE) |
302 | add_definitions(-DENABLE_DECODE) | |
303 | endif() | |
304 | ||
5f606159 JH |
305 | if(NOT DISABLE_WERROR) |
306 | add_definitions(-Werror) | |
307 | endif() | |
df944399 | 308 | |
9632990d UH |
309 | if(ENABLE_SIGNALS) |
310 | add_definitions(-DENABLE_SIGNALS) | |
311 | endif() | |
312 | ||
30588653 AG |
313 | #=============================================================================== |
314 | #= Global Include Directories | |
315 | #------------------------------------------------------------------------------- | |
316 | ||
b04e278d AG |
317 | include_directories( |
318 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 319 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d | 320 | ${Boost_INCLUDE_DIRS} |
9e8e84fc | 321 | ${QT_INCLUDE_DIRS} |
b04e278d AG |
322 | ) |
323 | ||
324 | if(STATIC_PKGDEPS_LIBS) | |
325 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
326 | else() | |
327 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
328 | endif() | |
df944399 | 329 | |
30588653 AG |
330 | #=============================================================================== |
331 | #= Linker Configuration | |
332 | #------------------------------------------------------------------------------- | |
333 | ||
b04e278d AG |
334 | link_directories(${Boost_LIBRARY_DIRS}) |
335 | ||
336 | set(PULSEVIEW_LINK_LIBS | |
337 | ${Boost_LIBRARIES} | |
338 | ${QT_LIBRARIES} | |
2b76309a | 339 | ${CMAKE_THREAD_LIBS_INIT} |
b04e278d AG |
340 | ) |
341 | ||
342 | if(STATIC_PKGDEPS_LIBS) | |
343 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
344 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
7cfb538d UH |
345 | if(WIN32) |
346 | # Workaround for a MinGW linking issue. | |
347 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
348 | endif() | |
b04e278d AG |
349 | else() |
350 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
351 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
352 | endif() | |
df944399 | 353 | |
11a04e2a UH |
354 | if(WIN32) |
355 | # On Windows we need to statically link the libqsvg imageformat | |
356 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
357 | add_definitions(-DQT_STATICPLUGIN) | |
358 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
11a04e2a | 359 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") |
52f38de6 | 360 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) |
11a04e2a UH |
361 | endif() |
362 | ||
9137928c MC |
363 | if(ANDROID) |
364 | list(APPEND PULSEVIEW_LINK_LIBS "-llog") | |
365 | endif() | |
366 | ||
26807061 MC |
367 | if(ANDROID) |
368 | add_library(${PROJECT_NAME} SHARED | |
369 | ${pulseview_SOURCES} | |
370 | ${pulseview_HEADERS_MOC} | |
371 | ${pulseview_FORMS_HEADERS} | |
372 | ${pulseview_RESOURCES_RCC} | |
373 | ) | |
374 | else() | |
5a13850b | 375 | add_executable(${PROJECT_NAME} |
a8d3fb2d JH |
376 | ${pulseview_SOURCES} |
377 | ${pulseview_HEADERS_MOC} | |
378 | ${pulseview_FORMS_HEADERS} | |
379 | ${pulseview_RESOURCES_RCC} | |
df944399 | 380 | ) |
26807061 | 381 | endif() |
df944399 | 382 | |
5a13850b | 383 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 384 | |
b0d8c0dc | 385 | if(WIN32) |
61e1e13e UH |
386 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
387 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
388 | endif() |
389 | ||
30588653 AG |
390 | #=============================================================================== |
391 | #= Installation | |
392 | #------------------------------------------------------------------------------- | |
393 | ||
52bbe600 | 394 | # Install the executable. |
cd6606c2 AG |
395 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
396 | ||
52bbe600 UH |
397 | # Install the manpage. |
398 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
399 | ||
cd6606c2 AG |
400 | #=============================================================================== |
401 | #= Packaging (handled by CPack) | |
402 | #------------------------------------------------------------------------------- | |
403 | ||
b02a8cbf JH |
404 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
405 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
406 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
407 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
408 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
409 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
4b413894 JH |
410 | set(CPACK_SOURCE_PACKAGE_FILE_NAME |
411 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
1d2fb87d | 412 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
413 | |
414 | include(CPack) | |
bc1c1462 | 415 | |
30588653 AG |
416 | #=============================================================================== |
417 | #= Tests | |
418 | #------------------------------------------------------------------------------- | |
419 | ||
77e8ac52 | 420 | if(ENABLE_TESTS) |
fb746bcc | 421 | add_subdirectory(test) |
951c583c | 422 | enable_testing() |
fb746bcc | 423 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 424 | endif() |