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