]>
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 |
0c0e1888 | 149 | pv/widgets/wellarray.cpp |
df944399 JH |
150 | ) |
151 | ||
0aad432c | 152 | # This list includes only QObject derived class headers. |
a8d3fb2d | 153 | set(pulseview_HEADERS |
51e77110 | 154 | pv/mainwindow.h |
51e77110 | 155 | pv/sigsession.h |
0fbda3c2 | 156 | pv/storesession.h |
acda14b8 | 157 | pv/dialogs/about.h |
9663c82b | 158 | pv/dialogs/connect.h |
0fbda3c2 | 159 | pv/dialogs/storeprogress.h |
51d4a9ab | 160 | pv/popups/probes.h |
269528f5 | 161 | pv/popups/deviceoptions.h |
b1fe148e JH |
162 | pv/prop/bool.h |
163 | pv/prop/double.h | |
164 | pv/prop/enum.h | |
165 | pv/prop/int.h | |
166 | pv/prop/property.h | |
167 | pv/prop/string.h | |
f4c92e1c | 168 | pv/toolbars/samplingbar.h |
3efda736 | 169 | pv/view/cursor.h |
1d8dca91 | 170 | pv/view/header.h |
b08d7222 | 171 | pv/view/logicsignal.h |
c23b29d6 | 172 | pv/view/marginwidget.h |
ccdd3ef5 | 173 | pv/view/ruler.h |
2a2512b2 JH |
174 | pv/view/selectableitem.h |
175 | pv/view/signal.h | |
3efda736 | 176 | pv/view/timemarker.h |
931f20b0 | 177 | pv/view/trace.h |
cdf7bea7 JH |
178 | pv/view/view.h |
179 | pv/view/viewport.h | |
91e8bf08 JH |
180 | pv/widgets/colourbutton.h |
181 | pv/widgets/colourpopup.h | |
0bce8609 | 182 | pv/widgets/popup.h |
6a91973f | 183 | pv/widgets/popuptoolbutton.h |
0c0e1888 | 184 | pv/widgets/wellarray.h |
df944399 JH |
185 | ) |
186 | ||
a8d3fb2d | 187 | set(pulseview_FORMS |
acda14b8 | 188 | pv/dialogs/about.ui |
df944399 JH |
189 | ) |
190 | ||
a8d3fb2d JH |
191 | set(pulseview_RESOURCES |
192 | pulseview.qrc | |
df944399 JH |
193 | ) |
194 | ||
140181a4 JH |
195 | if(ENABLE_SIGNALS) |
196 | list(APPEND pulseview_SOURCES signalhandler.cpp) | |
197 | list(APPEND pulseview_HEADERS signalhandler.h) | |
198 | endif() | |
199 | ||
269528f5 JH |
200 | if(ENABLE_DECODE) |
201 | list(APPEND pulseview_SOURCES | |
202 | pv/data/decoderstack.cpp | |
203 | pv/data/decode/annotation.cpp | |
204 | pv/data/decode/decoder.cpp | |
205 | pv/prop/binding/decoderoptions.cpp | |
206 | pv/view/decodetrace.cpp | |
207 | pv/widgets/decodergroupbox.cpp | |
208 | pv/widgets/decodermenu.cpp | |
269528f5 JH |
209 | ) |
210 | ||
211 | list(APPEND pulseview_HEADERS | |
212 | pv/data/decoderstack.h | |
213 | pv/view/decodetrace.h | |
214 | pv/widgets/decodergroupbox.h | |
215 | pv/widgets/decodermenu.h | |
216 | ) | |
217 | endif() | |
218 | ||
fe15e0bc UH |
219 | if(WIN32) |
220 | # Use the sigrok icon for the pulseview.exe executable. | |
221 | set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>") | |
222 | enable_language(RC) | |
61e1e13e | 223 | list(APPEND pulseview_SOURCES pulseviewico.rc) |
fe15e0bc UH |
224 | endif() |
225 | ||
a8d3fb2d JH |
226 | qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) |
227 | qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) | |
228 | qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) | |
df944399 JH |
229 | |
230 | include(${QT_USE_FILE}) | |
231 | ||
30588653 AG |
232 | #=============================================================================== |
233 | #= Global Definitions | |
234 | #------------------------------------------------------------------------------- | |
235 | ||
df944399 | 236 | add_definitions(${QT_DEFINITIONS}) |
ac223c1e | 237 | add_definitions(-D__STDC_LIMIT_MACROS) |
a9974171 | 238 | add_definitions(-Wall -Wextra) |
5f606159 | 239 | |
269528f5 JH |
240 | if(ENABLE_DECODE) |
241 | add_definitions(-DENABLE_DECODE) | |
242 | endif() | |
243 | ||
5f606159 JH |
244 | if(NOT DISABLE_WERROR) |
245 | add_definitions(-Werror) | |
246 | endif() | |
df944399 | 247 | |
30588653 AG |
248 | #=============================================================================== |
249 | #= Global Include Directories | |
250 | #------------------------------------------------------------------------------- | |
251 | ||
b04e278d AG |
252 | include_directories( |
253 | ${CMAKE_CURRENT_BINARY_DIR} | |
cef18fc6 | 254 | ${CMAKE_CURRENT_SOURCE_DIR} |
b04e278d AG |
255 | ${Boost_INCLUDE_DIRS} |
256 | ) | |
257 | ||
258 | if(STATIC_PKGDEPS_LIBS) | |
259 | include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) | |
260 | else() | |
261 | include_directories(${PKGDEPS_INCLUDE_DIRS}) | |
262 | endif() | |
df944399 | 263 | |
30588653 AG |
264 | #=============================================================================== |
265 | #= Linker Configuration | |
266 | #------------------------------------------------------------------------------- | |
267 | ||
b04e278d AG |
268 | link_directories(${Boost_LIBRARY_DIRS}) |
269 | ||
270 | set(PULSEVIEW_LINK_LIBS | |
271 | ${Boost_LIBRARIES} | |
3933e8a9 | 272 | ${CMAKE_THREAD_LIBS_INIT} |
b04e278d AG |
273 | ${QT_LIBRARIES} |
274 | ) | |
275 | ||
276 | if(STATIC_PKGDEPS_LIBS) | |
277 | link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) | |
278 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) | |
279 | else() | |
280 | link_directories(${PKGDEPS_LIBRARY_DIRS}) | |
281 | list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) | |
282 | endif() | |
df944399 | 283 | |
11a04e2a UH |
284 | if(WIN32) |
285 | # On Windows we need to statically link the libqsvg imageformat | |
286 | # plugin (and the QtSvg component) for SVG graphics/icons to work. | |
287 | add_definitions(-DQT_STATICPLUGIN) | |
288 | link_directories("${QT_PLUGINS_DIR}/imageformats") | |
289 | list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY}) | |
290 | list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") | |
291 | endif() | |
292 | ||
5a13850b | 293 | add_executable(${PROJECT_NAME} |
a8d3fb2d JH |
294 | ${pulseview_SOURCES} |
295 | ${pulseview_HEADERS_MOC} | |
296 | ${pulseview_FORMS_HEADERS} | |
297 | ${pulseview_RESOURCES_RCC} | |
df944399 JH |
298 | ) |
299 | ||
5a13850b | 300 | target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) |
f0fa92c6 | 301 | |
b0d8c0dc | 302 | if(WIN32) |
61e1e13e UH |
303 | # Pass -mwindows so that no "DOS box" opens when PulseView is started. |
304 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") | |
b0d8c0dc UH |
305 | endif() |
306 | ||
b2474b8d JH |
307 | if(ENABLE_COTIRE) |
308 | include(cotire) | |
309 | cotire(${PROJECT_NAME}) | |
310 | endif() | |
311 | ||
30588653 AG |
312 | #=============================================================================== |
313 | #= Installation | |
314 | #------------------------------------------------------------------------------- | |
315 | ||
52bbe600 | 316 | # Install the executable. |
cd6606c2 AG |
317 | install(TARGETS ${PROJECT_NAME} DESTINATION bin/) |
318 | ||
52bbe600 UH |
319 | # Install the manpage. |
320 | install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) | |
321 | ||
cd6606c2 AG |
322 | #=============================================================================== |
323 | #= Packaging (handled by CPack) | |
324 | #------------------------------------------------------------------------------- | |
325 | ||
b02a8cbf JH |
326 | set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR}) |
327 | set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR}) | |
328 | set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO}) | |
cd6606c2 AG |
329 | set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) |
330 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
331 | set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") | |
4b413894 JH |
332 | set(CPACK_SOURCE_PACKAGE_FILE_NAME |
333 | "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}") | |
1d2fb87d | 334 | set(CPACK_SOURCE_GENERATOR "TGZ") |
cd6606c2 AG |
335 | |
336 | include(CPack) | |
bc1c1462 | 337 | |
30588653 AG |
338 | #=============================================================================== |
339 | #= Tests | |
340 | #------------------------------------------------------------------------------- | |
341 | ||
77e8ac52 | 342 | if(ENABLE_TESTS) |
fb746bcc | 343 | add_subdirectory(test) |
951c583c | 344 | enable_testing() |
fb746bcc | 345 | add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test) |
0aad432c | 346 | endif() |