]>
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 | |
a8d3fb2d | 26 | project(pulseview) |
df944399 | 27 | |
cf2b5b64 UH |
28 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") |
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) |
9e8e84fc | 40 | option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE) |
b04e278d AG |
41 | |
42 | if(WIN32) | |
7d297a01 UH |
43 | # On Windows/MinGW we need to statically link to libraries. |
44 | # This option is user configurable, but enable it by default on win32. | |
b04e278d | 45 | set(STATIC_PKGDEPS_LIBS TRUE) |
6987ceeb | 46 | |
2a21747e UH |
47 | # For boost-thread we need two additional settings on win32: |
48 | set(Boost_USE_STATIC_LIBS ON) | |
49 | add_definitions(-DBOOST_THREAD_USE_LIB) | |
50 | ||
0aad432c | 51 | # Windows does not support UNIX signals. |
140181a4 | 52 | set(ENABLE_SIGNALS FALSE) |
b04e278d | 53 | endif() |
506523c1 | 54 | |
552f686e | 55 | if(NOT CMAKE_BUILD_TYPE) |
7591fe23 UH |
56 | set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING |
57 | "Choose the type of build (None, Debug, Release, RelWithDebInfo, MinSizeRel)." | |
58 | FORCE) | |
552f686e JH |
59 | endif() |
60 | ||
506523c1 | 61 | #=============================================================================== |
30588653 AG |
62 | #= Dependencies |
63 | #------------------------------------------------------------------------------- | |
64 | ||
e8d00928 | 65 | list(APPEND PKGDEPS libsigrokxx>=0.3.0) |
df944399 | 66 | |
269528f5 | 67 | if(ENABLE_DECODE) |
ab186d22 | 68 | list(APPEND PKGDEPS libsigrokdecode>=0.3.0) |
269528f5 JH |
69 | endif() |
70 | ||
aff51746 MC |
71 | if(ANDROID) |
72 | list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) | |
73 | endif() | |
74 | ||
d52d8455 JH |
75 | find_package(PkgConfig) |
76 | pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) | |
77 | ||
9e8e84fc MC |
78 | if(FORCE_QT4) |
79 | set(Qt5Core_FOUND FALSE) | |
80 | else() | |
81 | find_package(Qt5Core QUIET) | |
82 | endif() | |
83 | ||
84 | if(Qt5Core_FOUND) | |
85 | message("-- Using Qt5") | |
86 | find_package(Qt5Widgets REQUIRED) | |
87 | find_package(Qt5Gui REQUIRED) | |
726ea667 | 88 | find_package(Qt5Svg REQUIRED) |
1cd4be22 | 89 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") |
ea370bc6 | 90 | set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) |
726ea667 | 91 | set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg) |
9e8e84fc MC |
92 | add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) |
93 | else() | |
94 | find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) | |
52f38de6 | 95 | find_package(Qt4 REQUIRED QtCore QtGui QtSvg) |
9e8e84fc | 96 | endif() |
2e2946fe | 97 | |
2a21747e UH |
98 | if(WIN32) |
99 | # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'. | |
100 | # The library is named libboost_thread_win32* (not libboost_thread*). | |
101 | find_package(Boost 1.42 COMPONENTS filesystem system thread_win32 REQUIRED) | |
102 | else() | |
103 | find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED) | |
104 | endif() | |
df944399 | 105 | |
858ae630 UH |
106 | # Find the platform's thread library (needed for C++11 threads). |
107 | # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. | |
2b76309a AJ |
108 | find_package(Threads REQUIRED) |
109 | ||
9df8453f MC |
110 | #=============================================================================== |
111 | #= System Introspection | |
112 | #------------------------------------------------------------------------------- | |
113 | ||
114 | include(memaccess) | |
115 | memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) | |
116 | ||
075fb499 AG |
117 | #=============================================================================== |
118 | #= Config Header | |
119 | #------------------------------------------------------------------------------- | |
120 | ||
f7951df4 | 121 | set(PV_TITLE PulseView) |
d4384c6d | 122 | set(PV_DESCRIPTION "A GUI for sigrok") |
f7951df4 | 123 | |
075fb499 | 124 | set(PV_VERSION_MAJOR 0) |
744905d4 | 125 | set(PV_VERSION_MINOR 2) |
075fb499 AG |
126 | set(PV_VERSION_MICRO 0) |
127 | set(PV_VERSION_STRING | |
128 | ${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO} | |
129 | ) | |
130 | ||
131 | configure_file ( | |
132 | ${PROJECT_SOURCE_DIR}/config.h.in | |
133 | ${PROJECT_BINARY_DIR}/config.h | |
134 | ) | |
df944399 | 135 | |
30588653 AG |
136 | #=============================================================================== |
137 | #= Sources | |
138 | #------------------------------------------------------------------------------- | |
139 | ||
a8d3fb2d | 140 | set(pulseview_SOURCES |
df944399 | 141 | main.cpp |
dac1bb97 | 142 | pv/application.cpp |
107ca6d3 | 143 | pv/devicemanager.cpp |
51e77110 | 144 | pv/mainwindow.cpp |
51e77110 | 145 | pv/sigsession.cpp |
0fbda3c2 | 146 | pv/storesession.cpp |
f0c9f81c | 147 | pv/util.cpp |
1b1ec774 JH |
148 | pv/data/analog.cpp |
149 | pv/data/analogsnapshot.cpp | |
150 | pv/data/logic.cpp | |
151 | pv/data/logicsnapshot.cpp | |
152 | pv/data/signaldata.cpp | |
153 | pv/data/snapshot.cpp | |
acda14b8 | 154 | pv/dialogs/about.cpp |
9663c82b | 155 | pv/dialogs/connect.cpp |
0fbda3c2 | 156 | pv/dialogs/storeprogress.cpp |
51d4a9ab | 157 | pv/popups/deviceoptions.cpp |
6ac6242b | 158 | pv/popups/channels.cpp |
de1d99bb | 159 | pv/prop/bool.cpp |
b912c99c | 160 | pv/prop/double.cpp |
820c3dea | 161 | pv/prop/enum.cpp |
a2b92157 | 162 | pv/prop/int.cpp |
c8df6005 | 163 | pv/prop/property.cpp |
7112a458 | 164 | pv/prop/string.cpp |
c8df6005 | 165 | pv/prop/binding/binding.cpp |
3820592a | 166 | pv/prop/binding/deviceoptions.cpp |
f4c92e1c | 167 | pv/toolbars/samplingbar.cpp |
aba1dd16 | 168 | pv/view/analogsignal.cpp |
cabce982 | 169 | pv/view/cursor.cpp |
84a0d458 | 170 | pv/view/cursorheader.cpp |
b42d25c4 | 171 | pv/view/cursorpair.cpp |
1d8dca91 | 172 | pv/view/header.cpp |
c23b29d6 | 173 | pv/view/marginwidget.cpp |
8d634081 | 174 | pv/view/logicsignal.cpp |
23935421 | 175 | pv/view/rowitem.cpp |
18f7104f | 176 | pv/view/rowitemowner.cpp |
ccdd3ef5 | 177 | pv/view/ruler.cpp |
f1283456 | 178 | pv/view/selectableitem.cpp |
8d634081 | 179 | pv/view/signal.cpp |
cd6c8ee2 | 180 | pv/view/timemarker.cpp |
931f20b0 | 181 | pv/view/trace.cpp |
722930c1 | 182 | pv/view/tracegroup.cpp |
91e8bf08 | 183 | pv/view/tracepalette.cpp |
cdf7bea7 JH |
184 | pv/view/view.cpp |
185 | pv/view/viewport.cpp | |
91e8bf08 JH |
186 | pv/widgets/colourbutton.cpp |
187 | pv/widgets/colourpopup.cpp | |
6e3f046e | 188 | pv/widgets/popup.cpp |
6a91973f | 189 | pv/widgets/popuptoolbutton.cpp |
1198b887 | 190 | pv/widgets/sweeptimingwidget.cpp |
0c0e1888 | 191 | pv/widgets/wellarray.cpp |
df944399 JH |
192 | ) |
193 | ||
0aad432c | 194 | # This list includes only QObject derived class headers. |
a8d3fb2d | 195 | set(pulseview_HEADERS |
2acdb232 JH |
196 | pv/mainwindow.hpp |
197 | pv/sigsession.hpp | |
198 | pv/storesession.hpp | |
199 | pv/dialogs/about.hpp | |
200 | pv/dialogs/connect.hpp | |
201 | pv/dialogs/storeprogress.hpp | |
202 | pv/popups/channels.hpp | |
203 | pv/popups/deviceoptions.hpp | |
204 | pv/prop/bool.hpp | |
205 | pv/prop/double.hpp | |
206 | pv/prop/enum.hpp | |
207 | pv/prop/int.hpp | |
208 | pv/prop/property.hpp | |
209 | pv/prop/string.hpp | |
210 | pv/prop/binding/deviceoptions.hpp | |
211 | pv/toolbars/samplingbar.hpp | |
212 | pv/view/cursor.hpp | |
213 | pv/view/cursorheader.hpp | |
214 | pv/view/header.hpp | |
215 | pv/view/logicsignal.hpp | |
216 | pv/view/marginwidget.hpp | |
217 | pv/view/rowitem.hpp | |
218 | pv/view/ruler.hpp | |
219 | pv/view/selectableitem.hpp | |
220 | pv/view/signal.hpp | |
221 | pv/view/timemarker.hpp | |
222 | pv/view/trace.hpp | |
223 | pv/view/tracegroup.hpp | |
224 | pv/view/view.hpp | |
225 | pv/view/viewport.hpp | |
226 | pv/widgets/colourbutton.hpp | |
227 | pv/widgets/colourpopup.hpp | |
228 | pv/widgets/popup.hpp | |
229 | pv/widgets/popuptoolbutton.hpp | |
230 | pv/widgets/sweeptimingwidget.hpp | |
231 | pv/widgets/wellarray.hpp | |
df944399 JH |
232 | ) |
233 | ||
a8d3fb2d | 234 | set(pulseview_FORMS |
acda14b8 | 235 | pv/dialogs/about.ui |
df944399 JH |
236 | ) |
237 | ||
a8d3fb2d JH |
238 | set(pulseview_RESOURCES |
239 | pulseview.qrc | |
df944399 JH |
240 | ) |
241 | ||
140181a4 JH |
242 | if(ENABLE_SIGNALS) |
243 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
2acdb232 | 244 | list(APPEND pulseview_HEADERS signalhandler.hpp) |
140181a4 JH |
245 | endif() |
246 | ||
269528f5 JH |
247 | if(ENABLE_DECODE) |
248 | list(APPEND pulseview_SOURCES | |
249 | pv/data/decoderstack.cpp | |
250 | pv/data/decode/annotation.cpp | |
251 | pv/data/decode/decoder.cpp | |
f9101a91 JH |
252 | pv/data/decode/row.cpp |
253 | pv/data/decode/rowdata.cpp | |
269528f5 JH |
254 | pv/prop/binding/decoderoptions.cpp |
255 | pv/view/decodetrace.cpp | |
256 | pv/widgets/decodergroupbox.cpp | |
257 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
258 | ) |
259 | ||
260 | list(APPEND pulseview_HEADERS | |
2acdb232 JH |
261 | pv/data/decoderstack.hpp |
262 | pv/view/decodetrace.hpp | |
263 | pv/widgets/decodergroupbox.hpp | |
264 | pv/widgets/decodermenu.hpp | |
269528f5 JH |
265 | ) |
266 | endif() | |
267 | ||
fe15e0bc UH |
268 | if(WIN32) |
269 | # Use the sigrok icon for the pulseview.exe executable. | |
270 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
271 | enable_language(RC) | |
61e1e13e | 272 | list(APPEND pulseview_SOURCES pulseviewico.rc) |
fe15e0bc UH |
273 | endif() |
274 | ||
9137928c MC |
275 | if(ANDROID) |
276 | list(APPEND pulseview_SOURCES android/loghandler.cpp) | |
277 | endif() | |
278 | ||
9e8e84fc MC |
279 | if(Qt5Core_FOUND) |
280 | qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
281 | qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
282 | qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
283 | else() | |
284 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) | |
285 | qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
286 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
287 | include(${QT_USE_FILE}) | |
288 | endif() | |
df944399 | 289 | |
30588653 AG |
290 | #=============================================================================== |
291 | #= Global Definitions | |
292 | #------------------------------------------------------------------------------- | |
293 | ||
e9213170 | 294 | add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS) |
ac223c1e | 295 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 296 | add_definitions(-Wall -Wextra) |
95d43108 | 297 | add_definitions(-std=c++11) |
5f606159 | 298 | |
269528f5 JH |
299 | if(ENABLE_DECODE) |
300 | add_definitions(-DENABLE_DECODE) | |
301 | endif() | |
302 | ||
5f606159 JH |
303 | if(NOT DISABLE_WERROR) |
304 | add_definitions(-Werror) | |
305 | endif() | |
df944399 | 306 | |
9632990d UH |
307 | if(ENABLE_SIGNALS) |
308 | add_definitions(-DENABLE_SIGNALS) | |
309 | endif() | |
310 | ||
30588653 AG |
311 | #=============================================================================== |
312 | #= Global Include Directories | |
313 | #------------------------------------------------------------------------------- | |
314 | ||
b04e278d AG |
315 | include_directories( |
316 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 317 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d | 318 | ${Boost_INCLUDE_DIRS} |
9e8e84fc | 319 | ${QT_INCLUDE_DIRS} |
b04e278d AG |
320 | ) |
321 | ||
322 | if(STATIC_PKGDEPS_LIBS) | |
323 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
324 | else() | |
325 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
326 | endif() | |
df944399 | 327 | |
30588653 AG |
328 | #=============================================================================== |
329 | #= Linker Configuration | |
330 | #------------------------------------------------------------------------------- | |
331 | ||
b04e278d AG |
332 | link_directories(${Boost_LIBRARY_DIRS}) |
333 | ||
334 | set(PULSEVIEW_LINK_LIBS | |
335 | ${Boost_LIBRARIES} | |
336 | ${QT_LIBRARIES} | |
2b76309a | 337 | ${CMAKE_THREAD_LIBS_INIT} |
b04e278d AG |
338 | ) |
339 | ||
340 | if(STATIC_PKGDEPS_LIBS) | |
341 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
342 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
7cfb538d UH |
343 | if(WIN32) |
344 | # Workaround for a MinGW linking issue. | |
345 | list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") | |
346 | endif() | |
b04e278d AG |
347 | else() |
348 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
349 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
350 | endif() | |
df944399 | 351 | |
11a04e2a UH |
352 | if(WIN32) |
353 | # On Windows we need to statically link the libqsvg imageformat | |
354 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
355 | add_definitions(-DQT_STATICPLUGIN) | |
356 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
11a04e2a | 357 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") |
52f38de6 | 358 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) |
11a04e2a UH |
359 | endif() |
360 | ||
9137928c MC |
361 | if(ANDROID) |
362 | list(APPEND PULSEVIEW_LINK_LIBS "-llog") | |
363 | endif() | |
364 | ||
26807061 MC |
365 | if(ANDROID) |
366 | add_library(${PROJECT_NAME} SHARED | |
367 | ${pulseview_SOURCES} | |
368 | ${pulseview_HEADERS_MOC} | |
369 | ${pulseview_FORMS_HEADERS} | |
370 | ${pulseview_RESOURCES_RCC} | |
371 | ) | |
372 | else() | |
5a13850b | 373 | add_executable(${PROJECT_NAME} |
a8d3fb2d JH |
374 | ${pulseview_SOURCES} |
375 | ${pulseview_HEADERS_MOC} | |
376 | ${pulseview_FORMS_HEADERS} | |
377 | ${pulseview_RESOURCES_RCC} | |
df944399 | 378 | ) |
26807061 | 379 | endif() |
df944399 | 380 | |
5a13850b | 381 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 382 | |
b0d8c0dc | 383 | if(WIN32) |
61e1e13e UH |
384 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
385 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
386 | endif() |
387 | ||
b2474b8d JH |
388 | if(ENABLE_COTIRE) |
389 | include(cotire) | |
390 | cotire(${PROJECT_NAME}) | |
391 | endif() | |
392 | ||
30588653 AG |
393 | #=============================================================================== |
394 | #= Installation | |
395 | #------------------------------------------------------------------------------- | |
396 | ||
52bbe600 | 397 | # Install the executable. |
cd6606c2 AG |
398 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
399 | ||
52bbe600 UH |
400 | # Install the manpage. |
401 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
402 | ||
cd6606c2 AG |
403 | #=============================================================================== |
404 | #= Packaging (handled by CPack) | |
405 | #------------------------------------------------------------------------------- | |
406 | ||
b02a8cbf JH |
407 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
408 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
409 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
410 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
411 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
412 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
4b413894 JH |
413 | set(CPACK_SOURCE_PACKAGE_FILE_NAME |
414 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
1d2fb87d | 415 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
416 | |
417 | include(CPack) | |
bc1c1462 | 418 | |
30588653 AG |
419 | #=============================================================================== |
420 | #= Tests | |
421 | #------------------------------------------------------------------------------- | |
422 | ||
77e8ac52 | 423 | if(ENABLE_TESTS) |
fb746bcc | 424 | add_subdirectory(test) |
951c583c | 425 | enable_testing() |
fb746bcc | 426 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 427 | endif() |