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