]>
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 |
84a0d458 | 138 | pv/view/cursorheader.cpp |
b42d25c4 | 139 | pv/view/cursorpair.cpp |
1d8dca91 | 140 | pv/view/header.cpp |
c23b29d6 | 141 | pv/view/marginwidget.cpp |
8d634081 | 142 | pv/view/logicsignal.cpp |
ccdd3ef5 | 143 | pv/view/ruler.cpp |
f1283456 | 144 | pv/view/selectableitem.cpp |
8d634081 | 145 | pv/view/signal.cpp |
cd6c8ee2 | 146 | pv/view/timemarker.cpp |
931f20b0 | 147 | pv/view/trace.cpp |
91e8bf08 | 148 | pv/view/tracepalette.cpp |
cdf7bea7 JH |
149 | pv/view/view.cpp |
150 | pv/view/viewport.cpp | |
91e8bf08 JH |
151 | pv/widgets/colourbutton.cpp |
152 | pv/widgets/colourpopup.cpp | |
6e3f046e | 153 | pv/widgets/popup.cpp |
6a91973f | 154 | pv/widgets/popuptoolbutton.cpp |
1198b887 | 155 | pv/widgets/sweeptimingwidget.cpp |
0c0e1888 | 156 | pv/widgets/wellarray.cpp |
df944399 JH |
157 | ) |
158 | ||
0aad432c | 159 | # This list includes only QObject derived class headers. |
a8d3fb2d | 160 | set(pulseview_HEADERS |
51e77110 | 161 | pv/mainwindow.h |
51e77110 | 162 | pv/sigsession.h |
0fbda3c2 | 163 | pv/storesession.h |
94574501 | 164 | pv/device/devinst.h |
acda14b8 | 165 | pv/dialogs/about.h |
9663c82b | 166 | pv/dialogs/connect.h |
0fbda3c2 | 167 | pv/dialogs/storeprogress.h |
51d4a9ab | 168 | pv/popups/probes.h |
269528f5 | 169 | pv/popups/deviceoptions.h |
b1fe148e JH |
170 | pv/prop/bool.h |
171 | pv/prop/double.h | |
172 | pv/prop/enum.h | |
173 | pv/prop/int.h | |
174 | pv/prop/property.h | |
175 | pv/prop/string.h | |
f4c92e1c | 176 | pv/toolbars/samplingbar.h |
3efda736 | 177 | pv/view/cursor.h |
84a0d458 | 178 | pv/view/cursorheader.h |
1d8dca91 | 179 | pv/view/header.h |
b08d7222 | 180 | pv/view/logicsignal.h |
c23b29d6 | 181 | pv/view/marginwidget.h |
ccdd3ef5 | 182 | pv/view/ruler.h |
2a2512b2 JH |
183 | pv/view/selectableitem.h |
184 | pv/view/signal.h | |
3efda736 | 185 | pv/view/timemarker.h |
931f20b0 | 186 | pv/view/trace.h |
cdf7bea7 JH |
187 | pv/view/view.h |
188 | pv/view/viewport.h | |
91e8bf08 JH |
189 | pv/widgets/colourbutton.h |
190 | pv/widgets/colourpopup.h | |
0bce8609 | 191 | pv/widgets/popup.h |
6a91973f | 192 | pv/widgets/popuptoolbutton.h |
1198b887 | 193 | pv/widgets/sweeptimingwidget.h |
0c0e1888 | 194 | pv/widgets/wellarray.h |
df944399 JH |
195 | ) |
196 | ||
a8d3fb2d | 197 | set(pulseview_FORMS |
acda14b8 | 198 | pv/dialogs/about.ui |
df944399 JH |
199 | ) |
200 | ||
a8d3fb2d JH |
201 | set(pulseview_RESOURCES |
202 | pulseview.qrc | |
df944399 JH |
203 | ) |
204 | ||
140181a4 JH |
205 | if(ENABLE_SIGNALS) |
206 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
207 | list(APPEND pulseview_HEADERS signalhandler.h) | |
208 | endif() | |
209 | ||
269528f5 JH |
210 | if(ENABLE_DECODE) |
211 | list(APPEND pulseview_SOURCES | |
212 | pv/data/decoderstack.cpp | |
213 | pv/data/decode/annotation.cpp | |
214 | pv/data/decode/decoder.cpp | |
f9101a91 JH |
215 | pv/data/decode/row.cpp |
216 | pv/data/decode/rowdata.cpp | |
269528f5 JH |
217 | pv/prop/binding/decoderoptions.cpp |
218 | pv/view/decodetrace.cpp | |
219 | pv/widgets/decodergroupbox.cpp | |
220 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
221 | ) |
222 | ||
223 | list(APPEND pulseview_HEADERS | |
224 | pv/data/decoderstack.h | |
225 | pv/view/decodetrace.h | |
226 | pv/widgets/decodergroupbox.h | |
227 | pv/widgets/decodermenu.h | |
228 | ) | |
229 | endif() | |
230 | ||
fe15e0bc UH |
231 | if(WIN32) |
232 | # Use the sigrok icon for the pulseview.exe executable. | |
233 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
234 | enable_language(RC) | |
61e1e13e | 235 | list(APPEND pulseview_SOURCES pulseviewico.rc) |
fe15e0bc UH |
236 | endif() |
237 | ||
a8d3fb2d JH |
238 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) |
239 | qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
240 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
df944399 JH |
241 | |
242 | include(${QT_USE_FILE}) | |
243 | ||
30588653 AG |
244 | #=============================================================================== |
245 | #= Global Definitions | |
246 | #------------------------------------------------------------------------------- | |
247 | ||
df944399 | 248 | add_definitions(${QT_DEFINITIONS}) |
ac223c1e | 249 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 250 | add_definitions(-Wall -Wextra) |
95d43108 | 251 | add_definitions(-std=c++11) |
5f606159 | 252 | |
269528f5 JH |
253 | if(ENABLE_DECODE) |
254 | add_definitions(-DENABLE_DECODE) | |
255 | endif() | |
256 | ||
5f606159 JH |
257 | if(NOT DISABLE_WERROR) |
258 | add_definitions(-Werror) | |
259 | endif() | |
df944399 | 260 | |
30588653 AG |
261 | #=============================================================================== |
262 | #= Global Include Directories | |
263 | #------------------------------------------------------------------------------- | |
264 | ||
b04e278d AG |
265 | include_directories( |
266 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 267 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d AG |
268 | ${Boost_INCLUDE_DIRS} |
269 | ) | |
270 | ||
271 | if(STATIC_PKGDEPS_LIBS) | |
272 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
273 | else() | |
274 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
275 | endif() | |
df944399 | 276 | |
30588653 AG |
277 | #=============================================================================== |
278 | #= Linker Configuration | |
279 | #------------------------------------------------------------------------------- | |
280 | ||
b04e278d AG |
281 | link_directories(${Boost_LIBRARY_DIRS}) |
282 | ||
283 | set(PULSEVIEW_LINK_LIBS | |
284 | ${Boost_LIBRARIES} | |
285 | ${QT_LIBRARIES} | |
286 | ) | |
287 | ||
288 | if(STATIC_PKGDEPS_LIBS) | |
289 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
290 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
7cfb538d UH |
291 | if(WIN32) |
292 | # Workaround for a MinGW linking issue. | |
293 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
294 | endif() | |
b04e278d AG |
295 | else() |
296 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
297 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
298 | endif() | |
df944399 | 299 | |
11a04e2a UH |
300 | if(WIN32) |
301 | # On Windows we need to statically link the libqsvg imageformat | |
302 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
303 | add_definitions(-DQT_STATICPLUGIN) | |
304 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
305 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) | |
306 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") | |
307 | endif() | |
308 | ||
5a13850b | 309 | add_executable(${PROJECT_NAME} |
a8d3fb2d JH |
310 | ${pulseview_SOURCES} |
311 | ${pulseview_HEADERS_MOC} | |
312 | ${pulseview_FORMS_HEADERS} | |
313 | ${pulseview_RESOURCES_RCC} | |
df944399 JH |
314 | ) |
315 | ||
5a13850b | 316 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 317 | |
b0d8c0dc | 318 | if(WIN32) |
61e1e13e UH |
319 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
320 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
321 | endif() |
322 | ||
b2474b8d JH |
323 | if(ENABLE_COTIRE) |
324 | include(cotire) | |
325 | cotire(${PROJECT_NAME}) | |
326 | endif() | |
327 | ||
30588653 AG |
328 | #=============================================================================== |
329 | #= Installation | |
330 | #------------------------------------------------------------------------------- | |
331 | ||
52bbe600 | 332 | # Install the executable. |
cd6606c2 AG |
333 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
334 | ||
52bbe600 UH |
335 | # Install the manpage. |
336 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
337 | ||
cd6606c2 AG |
338 | #=============================================================================== |
339 | #= Packaging (handled by CPack) | |
340 | #------------------------------------------------------------------------------- | |
341 | ||
b02a8cbf JH |
342 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
343 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
344 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
345 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
346 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
347 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
4b413894 JH |
348 | set(CPACK_SOURCE_PACKAGE_FILE_NAME |
349 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
1d2fb87d | 350 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
351 | |
352 | include(CPack) | |
bc1c1462 | 353 | |
30588653 AG |
354 | #=============================================================================== |
355 | #= Tests | |
356 | #------------------------------------------------------------------------------- | |
357 | ||
77e8ac52 | 358 | if(ENABLE_TESTS) |
fb746bcc | 359 | add_subdirectory(test) |
951c583c | 360 | enable_testing() |
fb746bcc | 361 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 362 | endif() |