]>
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 | project(pulseview) | |
27 | ||
28 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") | |
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 libsigrokxx>=0.3.0) | |
62 | ||
63 | if(ENABLE_DECODE) | |
64 | list(APPEND PKGDEPS libsigrokdecode>=0.3.0) | |
65 | endif() | |
66 | ||
67 | if(ANDROID) | |
68 | list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) | |
69 | endif() | |
70 | ||
71 | find_package(PkgConfig) | |
72 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) | |
73 | ||
74 | if(FORCE_QT4) | |
75 | set(Qt5Core_FOUND FALSE) | |
76 | else() | |
77 | find_package(Qt5Core QUIET) | |
78 | endif() | |
79 | ||
80 | if(Qt5Core_FOUND) | |
81 | message("-- Using Qt5") | |
82 | find_package(Qt5Widgets REQUIRED) | |
83 | find_package(Qt5Gui REQUIRED) | |
84 | find_package(Qt5Svg REQUIRED) | |
85 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") | |
86 | set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) | |
87 | set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg) | |
88 | add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) | |
89 | else() | |
90 | find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) | |
91 | find_package(Qt4 REQUIRED QtCore QtGui QtSvg) | |
92 | endif() | |
93 | ||
94 | find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED) | |
95 | ||
96 | # Find the platform's thread library (needed for C++11 threads). | |
97 | # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. | |
98 | find_package(Threads REQUIRED) | |
99 | ||
100 | #=============================================================================== | |
101 | #= System Introspection | |
102 | #------------------------------------------------------------------------------- | |
103 | ||
104 | include(memaccess) | |
105 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
106 | ||
107 | #=============================================================================== | |
108 | #= Config Header | |
109 | #------------------------------------------------------------------------------- | |
110 | ||
111 | set(PV_TITLE PulseView) | |
112 | set(PV_DESCRIPTION "A GUI for sigrok") | |
113 | ||
114 | set(PV_VERSION_MAJOR 0) | |
115 | set(PV_VERSION_MINOR 2) | |
116 | set(PV_VERSION_MICRO 0) | |
117 | set(PV_VERSION_STRING | |
118 | ${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO} | |
119 | ) | |
120 | ||
121 | configure_file ( | |
122 | ${PROJECT_SOURCE_DIR}/config.h.in | |
123 | ${PROJECT_BINARY_DIR}/config.h | |
124 | ) | |
125 | ||
126 | #=============================================================================== | |
127 | #= Sources | |
128 | #------------------------------------------------------------------------------- | |
129 | ||
130 | set(pulseview_SOURCES | |
131 | main.cpp | |
132 | pv/application.cpp | |
133 | pv/devicemanager.cpp | |
134 | pv/mainwindow.cpp | |
135 | pv/sigsession.cpp | |
136 | pv/storesession.cpp | |
137 | pv/util.cpp | |
138 | pv/data/analog.cpp | |
139 | pv/data/analogsnapshot.cpp | |
140 | pv/data/logic.cpp | |
141 | pv/data/logicsnapshot.cpp | |
142 | pv/data/signaldata.cpp | |
143 | pv/data/snapshot.cpp | |
144 | pv/dialogs/about.cpp | |
145 | pv/dialogs/connect.cpp | |
146 | pv/dialogs/storeprogress.cpp | |
147 | pv/popups/deviceoptions.cpp | |
148 | pv/popups/channels.cpp | |
149 | pv/prop/bool.cpp | |
150 | pv/prop/double.cpp | |
151 | pv/prop/enum.cpp | |
152 | pv/prop/int.cpp | |
153 | pv/prop/property.cpp | |
154 | pv/prop/string.cpp | |
155 | pv/prop/binding/binding.cpp | |
156 | pv/prop/binding/deviceoptions.cpp | |
157 | pv/toolbars/samplingbar.cpp | |
158 | pv/view/analogsignal.cpp | |
159 | pv/view/cursor.cpp | |
160 | pv/view/cursorheader.cpp | |
161 | pv/view/cursorpair.cpp | |
162 | pv/view/header.cpp | |
163 | pv/view/marginwidget.cpp | |
164 | pv/view/logicsignal.cpp | |
165 | pv/view/rowitem.cpp | |
166 | pv/view/rowitemowner.cpp | |
167 | pv/view/ruler.cpp | |
168 | pv/view/selectableitem.cpp | |
169 | pv/view/signal.cpp | |
170 | pv/view/timemarker.cpp | |
171 | pv/view/trace.cpp | |
172 | pv/view/tracegroup.cpp | |
173 | pv/view/tracepalette.cpp | |
174 | pv/view/view.cpp | |
175 | pv/view/viewport.cpp | |
176 | pv/widgets/colourbutton.cpp | |
177 | pv/widgets/colourpopup.cpp | |
178 | pv/widgets/popup.cpp | |
179 | pv/widgets/popuptoolbutton.cpp | |
180 | pv/widgets/sweeptimingwidget.cpp | |
181 | pv/widgets/wellarray.cpp | |
182 | ) | |
183 | ||
184 | # This list includes only QObject derived class headers. | |
185 | set(pulseview_HEADERS | |
186 | pv/mainwindow.h | |
187 | pv/sigsession.h | |
188 | pv/storesession.h | |
189 | pv/dialogs/about.h | |
190 | pv/dialogs/connect.h | |
191 | pv/dialogs/storeprogress.h | |
192 | pv/popups/channels.h | |
193 | pv/popups/deviceoptions.h | |
194 | pv/prop/bool.h | |
195 | pv/prop/double.h | |
196 | pv/prop/enum.h | |
197 | pv/prop/int.h | |
198 | pv/prop/property.h | |
199 | pv/prop/string.h | |
200 | pv/prop/binding/deviceoptions.h | |
201 | pv/toolbars/samplingbar.h | |
202 | pv/view/cursor.h | |
203 | pv/view/cursorheader.h | |
204 | pv/view/header.h | |
205 | pv/view/logicsignal.h | |
206 | pv/view/marginwidget.h | |
207 | pv/view/rowitem.h | |
208 | pv/view/ruler.h | |
209 | pv/view/selectableitem.h | |
210 | pv/view/signal.h | |
211 | pv/view/timemarker.h | |
212 | pv/view/trace.h | |
213 | pv/view/tracegroup.h | |
214 | pv/view/view.h | |
215 | pv/view/viewport.h | |
216 | pv/widgets/colourbutton.h | |
217 | pv/widgets/colourpopup.h | |
218 | pv/widgets/popup.h | |
219 | pv/widgets/popuptoolbutton.h | |
220 | pv/widgets/sweeptimingwidget.h | |
221 | pv/widgets/wellarray.h | |
222 | ) | |
223 | ||
224 | set(pulseview_FORMS | |
225 | pv/dialogs/about.ui | |
226 | ) | |
227 | ||
228 | set(pulseview_RESOURCES | |
229 | pulseview.qrc | |
230 | ) | |
231 | ||
232 | if(ENABLE_SIGNALS) | |
233 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
234 | list(APPEND pulseview_HEADERS signalhandler.h) | |
235 | endif() | |
236 | ||
237 | if(ENABLE_DECODE) | |
238 | list(APPEND pulseview_SOURCES | |
239 | pv/data/decoderstack.cpp | |
240 | pv/data/decode/annotation.cpp | |
241 | pv/data/decode/decoder.cpp | |
242 | pv/data/decode/row.cpp | |
243 | pv/data/decode/rowdata.cpp | |
244 | pv/prop/binding/decoderoptions.cpp | |
245 | pv/view/decodetrace.cpp | |
246 | pv/widgets/decodergroupbox.cpp | |
247 | pv/widgets/decodermenu.cpp | |
248 | ) | |
249 | ||
250 | list(APPEND pulseview_HEADERS | |
251 | pv/data/decoderstack.h | |
252 | pv/view/decodetrace.h | |
253 | pv/widgets/decodergroupbox.h | |
254 | pv/widgets/decodermenu.h | |
255 | ) | |
256 | endif() | |
257 | ||
258 | if(WIN32) | |
259 | # Use the sigrok icon for the pulseview.exe executable. | |
260 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
261 | enable_language(RC) | |
262 | list(APPEND pulseview_SOURCES pulseviewico.rc) | |
263 | endif() | |
264 | ||
265 | if(ANDROID) | |
266 | list(APPEND pulseview_SOURCES android/loghandler.cpp) | |
267 | endif() | |
268 | ||
269 | if(Qt5Core_FOUND) | |
270 | qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
271 | qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
272 | qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
273 | else() | |
274 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
275 | qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
276 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
277 | include(${QT_USE_FILE}) | |
278 | endif() | |
279 | ||
280 | #=============================================================================== | |
281 | #= Global Definitions | |
282 | #------------------------------------------------------------------------------- | |
283 | ||
284 | add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS) | |
285 | add_definitions(-D__STDC_LIMIT_MACROS) | |
286 | add_definitions(-Wall -Wextra) | |
287 | add_definitions(-std=c++11) | |
288 | ||
289 | if(ENABLE_DECODE) | |
290 | add_definitions(-DENABLE_DECODE) | |
291 | endif() | |
292 | ||
293 | if(NOT DISABLE_WERROR) | |
294 | add_definitions(-Werror) | |
295 | endif() | |
296 | ||
297 | if(ENABLE_SIGNALS) | |
298 | add_definitions(-DENABLE_SIGNALS) | |
299 | endif() | |
300 | ||
301 | #=============================================================================== | |
302 | #= Global Include Directories | |
303 | #------------------------------------------------------------------------------- | |
304 | ||
305 | include_directories( | |
306 | ${CMAKE_CURRENT_BINARY_DIR} | |
307 | ${CMAKE_CURRENT_SOURCE_DIR} | |
308 | ${Boost_INCLUDE_DIRS} | |
309 | ${QT_INCLUDE_DIRS} | |
310 | ) | |
311 | ||
312 | if(STATIC_PKGDEPS_LIBS) | |
313 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
314 | else() | |
315 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
316 | endif() | |
317 | ||
318 | #=============================================================================== | |
319 | #= Linker Configuration | |
320 | #------------------------------------------------------------------------------- | |
321 | ||
322 | link_directories(${Boost_LIBRARY_DIRS}) | |
323 | ||
324 | set(PULSEVIEW_LINK_LIBS | |
325 | ${Boost_LIBRARIES} | |
326 | ${QT_LIBRARIES} | |
327 | ${CMAKE_THREAD_LIBS_INIT} | |
328 | ) | |
329 | ||
330 | if(STATIC_PKGDEPS_LIBS) | |
331 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
332 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
333 | if(WIN32) | |
334 | # Workaround for a MinGW linking issue. | |
335 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
336 | endif() | |
337 | else() | |
338 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
339 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
340 | endif() | |
341 | ||
342 | if(WIN32) | |
343 | # On Windows we need to statically link the libqsvg imageformat | |
344 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
345 | add_definitions(-DQT_STATICPLUGIN) | |
346 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
347 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") | |
348 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) | |
349 | endif() | |
350 | ||
351 | if(ANDROID) | |
352 | list(APPEND PULSEVIEW_LINK_LIBS "-llog") | |
353 | endif() | |
354 | ||
355 | if(ANDROID) | |
356 | add_library(${PROJECT_NAME} SHARED | |
357 | ${pulseview_SOURCES} | |
358 | ${pulseview_HEADERS_MOC} | |
359 | ${pulseview_FORMS_HEADERS} | |
360 | ${pulseview_RESOURCES_RCC} | |
361 | ) | |
362 | else() | |
363 | add_executable(${PROJECT_NAME} | |
364 | ${pulseview_SOURCES} | |
365 | ${pulseview_HEADERS_MOC} | |
366 | ${pulseview_FORMS_HEADERS} | |
367 | ${pulseview_RESOURCES_RCC} | |
368 | ) | |
369 | endif() | |
370 | ||
371 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) | |
372 | ||
373 | if(WIN32) | |
374 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. | |
375 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
376 | endif() | |
377 | ||
378 | if(ENABLE_COTIRE) | |
379 | include(cotire) | |
380 | cotire(${PROJECT_NAME}) | |
381 | endif() | |
382 | ||
383 | #=============================================================================== | |
384 | #= Installation | |
385 | #------------------------------------------------------------------------------- | |
386 | ||
387 | # Install the executable. | |
388 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) | |
389 | ||
390 | # Install the manpage. | |
391 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
392 | ||
393 | #=============================================================================== | |
394 | #= Packaging (handled by CPack) | |
395 | #------------------------------------------------------------------------------- | |
396 | ||
397 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) | |
398 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
399 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
400 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) | |
401 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
402 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
403 | set(CPACK_SOURCE_PACKAGE_FILE_NAME | |
404 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
405 | set(CPACK_SOURCE_GENERATOR "TGZ") | |
406 | ||
407 | include(CPack) | |
408 | ||
409 | #=============================================================================== | |
410 | #= Tests | |
411 | #------------------------------------------------------------------------------- | |
412 | ||
413 | if(ENABLE_TESTS) | |
414 | add_subdirectory(test) | |
415 | enable_testing() | |
416 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) | |
417 | endif() |