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