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