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