]>
Commit | Line | Data |
---|---|---|
1 | ## | |
2 | ## This file is part of the PulseView project. | |
3 | ## | |
4 | ## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | ## Copyright (C) 2012-2013 Alexandru Gagniuc <mr.nuke.me@gmail.com> | |
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 | ||
21 | cmake_minimum_required(VERSION 2.8.6) | |
22 | ||
23 | include(FindPkgConfig) | |
24 | include(GNUInstallDirs) | |
25 | ||
26 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") | |
27 | ||
28 | project(pulseview) | |
29 | ||
30 | #=============================================================================== | |
31 | #= User Options | |
32 | #------------------------------------------------------------------------------- | |
33 | ||
34 | option(DISABLE_WERROR "Build without -Werror" FALSE) | |
35 | option(ENABLE_SIGNALS "Build with UNIX signals" TRUE) | |
36 | option(ENABLE_DECODE "Build with libsigrokdecode" TRUE) | |
37 | option(ENABLE_COTIRE "Enable cotire" FALSE) | |
38 | option(ENABLE_TESTS "Enable unit tests" FALSE) | |
39 | option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE) | |
40 | ||
41 | if(WIN32) | |
42 | # On Windows/MinGW we need to statically link to libraries. | |
43 | # This option is user configurable, but enable it by default on win32. | |
44 | set(STATIC_PKGDEPS_LIBS TRUE) | |
45 | ||
46 | # Windows does not support UNIX signals. | |
47 | set(ENABLE_SIGNALS FALSE) | |
48 | endif() | |
49 | ||
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 | ||
56 | #=============================================================================== | |
57 | #= Dependencies | |
58 | #------------------------------------------------------------------------------- | |
59 | ||
60 | list(APPEND PKGDEPS libsigrok>=0.3.0) | |
61 | ||
62 | if(ENABLE_DECODE) | |
63 | list(APPEND PKGDEPS libsigrokdecode>=0.3.0) | |
64 | endif() | |
65 | ||
66 | find_package(PkgConfig) | |
67 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) | |
68 | ||
69 | find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) | |
70 | find_package(Qt4 REQUIRED) | |
71 | ||
72 | find_package(Boost 1.42 COMPONENTS filesystem system REQUIRED) | |
73 | ||
74 | #=============================================================================== | |
75 | #= System Introspection | |
76 | #------------------------------------------------------------------------------- | |
77 | ||
78 | include(memaccess) | |
79 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
80 | ||
81 | #=============================================================================== | |
82 | #= Config Header | |
83 | #------------------------------------------------------------------------------- | |
84 | ||
85 | set(PV_TITLE PulseView) | |
86 | set(PV_DESCRIPTION "A GUI for sigrok") | |
87 | ||
88 | set(PV_VERSION_MAJOR 0) | |
89 | set(PV_VERSION_MINOR 2) | |
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 | ) | |
99 | ||
100 | #=============================================================================== | |
101 | #= Sources | |
102 | #------------------------------------------------------------------------------- | |
103 | ||
104 | set(pulseview_SOURCES | |
105 | main.cpp | |
106 | pv/devicemanager.cpp | |
107 | pv/mainwindow.cpp | |
108 | pv/sigsession.cpp | |
109 | pv/storesession.cpp | |
110 | pv/util.cpp | |
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 | |
117 | pv/device/device.cpp | |
118 | pv/device/file.cpp | |
119 | pv/device/devinst.cpp | |
120 | pv/device/inputfile.cpp | |
121 | pv/device/sessionfile.cpp | |
122 | pv/dialogs/about.cpp | |
123 | pv/dialogs/connect.cpp | |
124 | pv/dialogs/storeprogress.cpp | |
125 | pv/popups/deviceoptions.cpp | |
126 | pv/popups/probes.cpp | |
127 | pv/prop/bool.cpp | |
128 | pv/prop/double.cpp | |
129 | pv/prop/enum.cpp | |
130 | pv/prop/int.cpp | |
131 | pv/prop/property.cpp | |
132 | pv/prop/string.cpp | |
133 | pv/prop/binding/binding.cpp | |
134 | pv/prop/binding/deviceoptions.cpp | |
135 | pv/toolbars/samplingbar.cpp | |
136 | pv/view/analogsignal.cpp | |
137 | pv/view/cursor.cpp | |
138 | pv/view/cursorheader.cpp | |
139 | pv/view/cursorpair.cpp | |
140 | pv/view/header.cpp | |
141 | pv/view/marginwidget.cpp | |
142 | pv/view/logicsignal.cpp | |
143 | pv/view/ruler.cpp | |
144 | pv/view/selectableitem.cpp | |
145 | pv/view/signal.cpp | |
146 | pv/view/timemarker.cpp | |
147 | pv/view/trace.cpp | |
148 | pv/view/tracepalette.cpp | |
149 | pv/view/view.cpp | |
150 | pv/view/viewport.cpp | |
151 | pv/widgets/colourbutton.cpp | |
152 | pv/widgets/colourpopup.cpp | |
153 | pv/widgets/popup.cpp | |
154 | pv/widgets/popuptoolbutton.cpp | |
155 | pv/widgets/sweeptimingwidget.cpp | |
156 | pv/widgets/wellarray.cpp | |
157 | ) | |
158 | ||
159 | # This list includes only QObject derived class headers. | |
160 | set(pulseview_HEADERS | |
161 | pv/mainwindow.h | |
162 | pv/sigsession.h | |
163 | pv/storesession.h | |
164 | pv/device/devinst.h | |
165 | pv/dialogs/about.h | |
166 | pv/dialogs/connect.h | |
167 | pv/dialogs/storeprogress.h | |
168 | pv/popups/probes.h | |
169 | pv/popups/deviceoptions.h | |
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 | |
176 | pv/toolbars/samplingbar.h | |
177 | pv/view/cursor.h | |
178 | pv/view/cursorheader.h | |
179 | pv/view/header.h | |
180 | pv/view/logicsignal.h | |
181 | pv/view/marginwidget.h | |
182 | pv/view/ruler.h | |
183 | pv/view/selectableitem.h | |
184 | pv/view/signal.h | |
185 | pv/view/timemarker.h | |
186 | pv/view/trace.h | |
187 | pv/view/view.h | |
188 | pv/view/viewport.h | |
189 | pv/widgets/colourbutton.h | |
190 | pv/widgets/colourpopup.h | |
191 | pv/widgets/popup.h | |
192 | pv/widgets/popuptoolbutton.h | |
193 | pv/widgets/sweeptimingwidget.h | |
194 | pv/widgets/wellarray.h | |
195 | ) | |
196 | ||
197 | set(pulseview_FORMS | |
198 | pv/dialogs/about.ui | |
199 | ) | |
200 | ||
201 | set(pulseview_RESOURCES | |
202 | pulseview.qrc | |
203 | ) | |
204 | ||
205 | if(ENABLE_SIGNALS) | |
206 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
207 | list(APPEND pulseview_HEADERS signalhandler.h) | |
208 | endif() | |
209 | ||
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 | |
215 | pv/data/decode/row.cpp | |
216 | pv/data/decode/rowdata.cpp | |
217 | pv/prop/binding/decoderoptions.cpp | |
218 | pv/view/decodetrace.cpp | |
219 | pv/widgets/decodergroupbox.cpp | |
220 | pv/widgets/decodermenu.cpp | |
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 | ||
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) | |
235 | list(APPEND pulseview_SOURCES pulseviewico.rc) | |
236 | endif() | |
237 | ||
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}) | |
241 | ||
242 | include(${QT_USE_FILE}) | |
243 | ||
244 | #=============================================================================== | |
245 | #= Global Definitions | |
246 | #------------------------------------------------------------------------------- | |
247 | ||
248 | add_definitions(${QT_DEFINITIONS}) | |
249 | add_definitions(-D__STDC_LIMIT_MACROS) | |
250 | add_definitions(-Wall -Wextra) | |
251 | add_definitions(-std=c++11) | |
252 | ||
253 | if(ENABLE_DECODE) | |
254 | add_definitions(-DENABLE_DECODE) | |
255 | endif() | |
256 | ||
257 | if(NOT DISABLE_WERROR) | |
258 | add_definitions(-Werror) | |
259 | endif() | |
260 | ||
261 | #=============================================================================== | |
262 | #= Global Include Directories | |
263 | #------------------------------------------------------------------------------- | |
264 | ||
265 | include_directories( | |
266 | ${CMAKE_CURRENT_BINARY_DIR} | |
267 | ${CMAKE_CURRENT_SOURCE_DIR} | |
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() | |
276 | ||
277 | #=============================================================================== | |
278 | #= Linker Configuration | |
279 | #------------------------------------------------------------------------------- | |
280 | ||
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}) | |
291 | if(WIN32) | |
292 | # Workaround for a MinGW linking issue. | |
293 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
294 | endif() | |
295 | else() | |
296 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
297 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
298 | endif() | |
299 | ||
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 | ||
309 | add_executable(${PROJECT_NAME} | |
310 | ${pulseview_SOURCES} | |
311 | ${pulseview_HEADERS_MOC} | |
312 | ${pulseview_FORMS_HEADERS} | |
313 | ${pulseview_RESOURCES_RCC} | |
314 | ) | |
315 | ||
316 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) | |
317 | ||
318 | if(WIN32) | |
319 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. | |
320 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
321 | endif() | |
322 | ||
323 | if(ENABLE_COTIRE) | |
324 | include(cotire) | |
325 | cotire(${PROJECT_NAME}) | |
326 | endif() | |
327 | ||
328 | #=============================================================================== | |
329 | #= Installation | |
330 | #------------------------------------------------------------------------------- | |
331 | ||
332 | # Install the executable. | |
333 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) | |
334 | ||
335 | # Install the manpage. | |
336 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
337 | ||
338 | #=============================================================================== | |
339 | #= Packaging (handled by CPack) | |
340 | #------------------------------------------------------------------------------- | |
341 | ||
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}) | |
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") | |
348 | set(CPACK_SOURCE_PACKAGE_FILE_NAME | |
349 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
350 | set(CPACK_SOURCE_GENERATOR "TGZ") | |
351 | ||
352 | include(CPack) | |
353 | ||
354 | #=============================================================================== | |
355 | #= Tests | |
356 | #------------------------------------------------------------------------------- | |
357 | ||
358 | if(ENABLE_TESTS) | |
359 | add_subdirectory(test) | |
360 | enable_testing() | |
361 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) | |
362 | endif() |