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