]>
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 | option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE) | |
41 | ||
42 | if(WIN32) | |
43 | # On Windows/MinGW we need to statically link to libraries. | |
44 | # This option is user configurable, but enable it by default on win32. | |
45 | set(STATIC_PKGDEPS_LIBS TRUE) | |
46 | ||
47 | # Windows does not support UNIX signals. | |
48 | set(ENABLE_SIGNALS FALSE) | |
49 | endif() | |
50 | ||
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 | ||
57 | #=============================================================================== | |
58 | #= Dependencies | |
59 | #------------------------------------------------------------------------------- | |
60 | ||
61 | list(APPEND PKGDEPS libsigrok>=0.3.0) | |
62 | ||
63 | if(ENABLE_DECODE) | |
64 | list(APPEND PKGDEPS libsigrokdecode>=0.3.0) | |
65 | endif() | |
66 | ||
67 | find_package(PkgConfig) | |
68 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) | |
69 | ||
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) | |
80 | set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}) | |
81 | set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) | |
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() | |
88 | ||
89 | find_package(Boost 1.42 COMPONENTS filesystem system REQUIRED) | |
90 | ||
91 | #=============================================================================== | |
92 | #= System Introspection | |
93 | #------------------------------------------------------------------------------- | |
94 | ||
95 | include(memaccess) | |
96 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
97 | ||
98 | #=============================================================================== | |
99 | #= Config Header | |
100 | #------------------------------------------------------------------------------- | |
101 | ||
102 | set(PV_TITLE PulseView) | |
103 | set(PV_DESCRIPTION "A GUI for sigrok") | |
104 | ||
105 | set(PV_VERSION_MAJOR 0) | |
106 | set(PV_VERSION_MINOR 2) | |
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 | ) | |
116 | ||
117 | #=============================================================================== | |
118 | #= Sources | |
119 | #------------------------------------------------------------------------------- | |
120 | ||
121 | set(pulseview_SOURCES | |
122 | main.cpp | |
123 | pv/devicemanager.cpp | |
124 | pv/mainwindow.cpp | |
125 | pv/sigsession.cpp | |
126 | pv/storesession.cpp | |
127 | pv/util.cpp | |
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 | |
134 | pv/device/device.cpp | |
135 | pv/device/file.cpp | |
136 | pv/device/devinst.cpp | |
137 | pv/device/inputfile.cpp | |
138 | pv/device/sessionfile.cpp | |
139 | pv/dialogs/about.cpp | |
140 | pv/dialogs/connect.cpp | |
141 | pv/dialogs/storeprogress.cpp | |
142 | pv/popups/deviceoptions.cpp | |
143 | pv/popups/probes.cpp | |
144 | pv/prop/bool.cpp | |
145 | pv/prop/double.cpp | |
146 | pv/prop/enum.cpp | |
147 | pv/prop/int.cpp | |
148 | pv/prop/property.cpp | |
149 | pv/prop/string.cpp | |
150 | pv/prop/binding/binding.cpp | |
151 | pv/prop/binding/deviceoptions.cpp | |
152 | pv/toolbars/samplingbar.cpp | |
153 | pv/view/analogsignal.cpp | |
154 | pv/view/cursor.cpp | |
155 | pv/view/cursorheader.cpp | |
156 | pv/view/cursorpair.cpp | |
157 | pv/view/header.cpp | |
158 | pv/view/marginwidget.cpp | |
159 | pv/view/logicsignal.cpp | |
160 | pv/view/ruler.cpp | |
161 | pv/view/selectableitem.cpp | |
162 | pv/view/signal.cpp | |
163 | pv/view/timemarker.cpp | |
164 | pv/view/trace.cpp | |
165 | pv/view/tracepalette.cpp | |
166 | pv/view/view.cpp | |
167 | pv/view/viewport.cpp | |
168 | pv/widgets/colourbutton.cpp | |
169 | pv/widgets/colourpopup.cpp | |
170 | pv/widgets/popup.cpp | |
171 | pv/widgets/popuptoolbutton.cpp | |
172 | pv/widgets/sweeptimingwidget.cpp | |
173 | pv/widgets/wellarray.cpp | |
174 | ) | |
175 | ||
176 | # This list includes only QObject derived class headers. | |
177 | set(pulseview_HEADERS | |
178 | pv/mainwindow.h | |
179 | pv/sigsession.h | |
180 | pv/storesession.h | |
181 | pv/device/devinst.h | |
182 | pv/dialogs/about.h | |
183 | pv/dialogs/connect.h | |
184 | pv/dialogs/storeprogress.h | |
185 | pv/popups/probes.h | |
186 | pv/popups/deviceoptions.h | |
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 | |
193 | pv/toolbars/samplingbar.h | |
194 | pv/view/cursor.h | |
195 | pv/view/cursorheader.h | |
196 | pv/view/header.h | |
197 | pv/view/logicsignal.h | |
198 | pv/view/marginwidget.h | |
199 | pv/view/ruler.h | |
200 | pv/view/selectableitem.h | |
201 | pv/view/signal.h | |
202 | pv/view/timemarker.h | |
203 | pv/view/trace.h | |
204 | pv/view/view.h | |
205 | pv/view/viewport.h | |
206 | pv/widgets/colourbutton.h | |
207 | pv/widgets/colourpopup.h | |
208 | pv/widgets/popup.h | |
209 | pv/widgets/popuptoolbutton.h | |
210 | pv/widgets/sweeptimingwidget.h | |
211 | pv/widgets/wellarray.h | |
212 | ) | |
213 | ||
214 | set(pulseview_FORMS | |
215 | pv/dialogs/about.ui | |
216 | ) | |
217 | ||
218 | set(pulseview_RESOURCES | |
219 | pulseview.qrc | |
220 | ) | |
221 | ||
222 | if(ENABLE_SIGNALS) | |
223 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
224 | list(APPEND pulseview_HEADERS signalhandler.h) | |
225 | endif() | |
226 | ||
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 | |
232 | pv/data/decode/row.cpp | |
233 | pv/data/decode/rowdata.cpp | |
234 | pv/prop/binding/decoderoptions.cpp | |
235 | pv/view/decodetrace.cpp | |
236 | pv/widgets/decodergroupbox.cpp | |
237 | pv/widgets/decodermenu.cpp | |
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 | ||
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) | |
252 | list(APPEND pulseview_SOURCES pulseviewico.rc) | |
253 | endif() | |
254 | ||
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() | |
265 | ||
266 | #=============================================================================== | |
267 | #= Global Definitions | |
268 | #------------------------------------------------------------------------------- | |
269 | ||
270 | add_definitions(${QT_DEFINITIONS}) | |
271 | add_definitions(-D__STDC_LIMIT_MACROS) | |
272 | add_definitions(-Wall -Wextra) | |
273 | add_definitions(-std=c++11) | |
274 | ||
275 | if(ENABLE_DECODE) | |
276 | add_definitions(-DENABLE_DECODE) | |
277 | endif() | |
278 | ||
279 | if(NOT DISABLE_WERROR) | |
280 | add_definitions(-Werror) | |
281 | endif() | |
282 | ||
283 | #=============================================================================== | |
284 | #= Global Include Directories | |
285 | #------------------------------------------------------------------------------- | |
286 | ||
287 | include_directories( | |
288 | ${CMAKE_CURRENT_BINARY_DIR} | |
289 | ${CMAKE_CURRENT_SOURCE_DIR} | |
290 | ${Boost_INCLUDE_DIRS} | |
291 | ${QT_INCLUDE_DIRS} | |
292 | ) | |
293 | ||
294 | if(STATIC_PKGDEPS_LIBS) | |
295 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
296 | else() | |
297 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
298 | endif() | |
299 | ||
300 | #=============================================================================== | |
301 | #= Linker Configuration | |
302 | #------------------------------------------------------------------------------- | |
303 | ||
304 | link_directories(${Boost_LIBRARY_DIRS}) | |
305 | ||
306 | set(PULSEVIEW_LINK_LIBS | |
307 | ${Boost_LIBRARIES} | |
308 | ${QT_LIBRARIES} | |
309 | ) | |
310 | ||
311 | if(STATIC_PKGDEPS_LIBS) | |
312 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
313 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
314 | if(WIN32) | |
315 | # Workaround for a MinGW linking issue. | |
316 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
317 | endif() | |
318 | else() | |
319 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
320 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
321 | endif() | |
322 | ||
323 | if(WIN32) | |
324 | # On Windows we need to statically link the libqsvg imageformat | |
325 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
326 | add_definitions(-DQT_STATICPLUGIN) | |
327 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
328 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) | |
329 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") | |
330 | endif() | |
331 | ||
332 | add_executable(${PROJECT_NAME} | |
333 | ${pulseview_SOURCES} | |
334 | ${pulseview_HEADERS_MOC} | |
335 | ${pulseview_FORMS_HEADERS} | |
336 | ${pulseview_RESOURCES_RCC} | |
337 | ) | |
338 | ||
339 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) | |
340 | ||
341 | if(WIN32) | |
342 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. | |
343 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
344 | endif() | |
345 | ||
346 | if(ENABLE_COTIRE) | |
347 | include(cotire) | |
348 | cotire(${PROJECT_NAME}) | |
349 | endif() | |
350 | ||
351 | #=============================================================================== | |
352 | #= Installation | |
353 | #------------------------------------------------------------------------------- | |
354 | ||
355 | # Install the executable. | |
356 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) | |
357 | ||
358 | # Install the manpage. | |
359 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
360 | ||
361 | #=============================================================================== | |
362 | #= Packaging (handled by CPack) | |
363 | #------------------------------------------------------------------------------- | |
364 | ||
365 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) | |
366 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
367 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
368 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) | |
369 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
370 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
371 | set(CPACK_SOURCE_PACKAGE_FILE_NAME | |
372 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
373 | set(CPACK_SOURCE_GENERATOR "TGZ") | |
374 | ||
375 | include(CPack) | |
376 | ||
377 | #=============================================================================== | |
378 | #= Tests | |
379 | #------------------------------------------------------------------------------- | |
380 | ||
381 | if(ENABLE_TESTS) | |
382 | add_subdirectory(test) | |
383 | enable_testing() | |
384 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) | |
385 | endif() |