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