2 ## This file is part of the PulseView project.
4 ## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 ## Copyright (C) 2012-2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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.
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.
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/>.
21 cmake_minimum_required(VERSION 2.8.6)
23 include(FindPkgConfig)
24 include(GNUInstallDirs)
28 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
30 #===============================================================================
32 #-------------------------------------------------------------------------------
34 option(DISABLE_WERROR "Build without -Werror" FALSE)
35 option(ENABLE_SIGNALS "Build with UNIX signals" TRUE)
36 option(ENABLE_DECODE "Build with libsigrokdecode" TRUE)
37 option(ENABLE_COTIRE "Enable cotire" FALSE)
38 option(ENABLE_TESTS "Enable unit tests" FALSE)
39 option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE)
40 option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE)
43 # On Windows/MinGW we need to statically link to libraries.
44 # This option is user configurable, but enable it by default on win32.
45 set(STATIC_PKGDEPS_LIBS TRUE)
47 # Windows does not support UNIX signals.
48 set(ENABLE_SIGNALS FALSE)
51 if(NOT CMAKE_BUILD_TYPE)
52 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
53 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
57 #===============================================================================
59 #-------------------------------------------------------------------------------
61 list(APPEND PKGDEPS libsigrokxx>=0.3.0)
64 list(APPEND PKGDEPS libsigrokdecode>=0.3.0)
68 list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0)
71 find_package(PkgConfig)
72 pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
75 set(Qt5Core_FOUND FALSE)
77 find_package(Qt5Core QUIET)
81 message("-- Using Qt5")
82 find_package(Qt5Widgets REQUIRED)
83 find_package(Qt5Gui REQUIRED)
84 find_package(Qt5Svg REQUIRED)
85 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
86 set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
87 set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
88 add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
90 find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac)
91 find_package(Qt4 REQUIRED QtCore QtGui QtSvg)
94 find_package(Boost 1.42 COMPONENTS filesystem system REQUIRED)
96 # Find the platform's thread library (needed for C++11 threads).
97 # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
98 find_package(Threads REQUIRED)
100 #===============================================================================
101 #= System Introspection
102 #-------------------------------------------------------------------------------
105 memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS)
107 #===============================================================================
109 #-------------------------------------------------------------------------------
111 set(PV_TITLE PulseView)
112 set(PV_DESCRIPTION "A GUI for sigrok")
114 set(PV_VERSION_MAJOR 0)
115 set(PV_VERSION_MINOR 2)
116 set(PV_VERSION_MICRO 0)
117 set(PV_VERSION_STRING
118 ${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}
122 ${PROJECT_SOURCE_DIR}/config.h.in
123 ${PROJECT_BINARY_DIR}/config.h
126 #===============================================================================
128 #-------------------------------------------------------------------------------
130 set(pulseview_SOURCES
139 pv/data/analogsnapshot.cpp
141 pv/data/logicsnapshot.cpp
142 pv/data/signaldata.cpp
145 pv/dialogs/connect.cpp
146 pv/dialogs/storeprogress.cpp
147 pv/popups/deviceoptions.cpp
148 pv/popups/channels.cpp
155 pv/prop/binding/binding.cpp
156 pv/prop/binding/deviceoptions.cpp
157 pv/toolbars/samplingbar.cpp
158 pv/view/analogsignal.cpp
160 pv/view/cursorheader.cpp
161 pv/view/cursorpair.cpp
163 pv/view/marginwidget.cpp
164 pv/view/logicsignal.cpp
166 pv/view/selectableitem.cpp
168 pv/view/timemarker.cpp
170 pv/view/tracepalette.cpp
173 pv/widgets/colourbutton.cpp
174 pv/widgets/colourpopup.cpp
176 pv/widgets/popuptoolbutton.cpp
177 pv/widgets/sweeptimingwidget.cpp
178 pv/widgets/wellarray.cpp
181 # This list includes only QObject derived class headers.
182 set(pulseview_HEADERS
188 pv/dialogs/storeprogress.h
190 pv/popups/deviceoptions.h
197 pv/prop/binding/deviceoptions.h
198 pv/toolbars/samplingbar.h
200 pv/view/cursorheader.h
202 pv/view/logicsignal.h
203 pv/view/marginwidget.h
205 pv/view/selectableitem.h
211 pv/widgets/colourbutton.h
212 pv/widgets/colourpopup.h
214 pv/widgets/popuptoolbutton.h
215 pv/widgets/sweeptimingwidget.h
216 pv/widgets/wellarray.h
223 set(pulseview_RESOURCES
228 list(APPEND pulseview_SOURCES signalhandler.cpp)
229 list(APPEND pulseview_HEADERS signalhandler.h)
233 list(APPEND pulseview_SOURCES
234 pv/data/decoderstack.cpp
235 pv/data/decode/annotation.cpp
236 pv/data/decode/decoder.cpp
237 pv/data/decode/row.cpp
238 pv/data/decode/rowdata.cpp
239 pv/prop/binding/decoderoptions.cpp
240 pv/view/decodetrace.cpp
241 pv/widgets/decodergroupbox.cpp
242 pv/widgets/decodermenu.cpp
245 list(APPEND pulseview_HEADERS
246 pv/data/decoderstack.h
247 pv/view/decodetrace.h
248 pv/widgets/decodergroupbox.h
249 pv/widgets/decodermenu.h
254 # Use the sigrok icon for the pulseview.exe executable.
255 set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>")
257 list(APPEND pulseview_SOURCES pulseviewico.rc)
261 list(APPEND pulseview_SOURCES android/loghandler.cpp)
265 qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
266 qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
267 qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
269 qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
270 qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
271 qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
272 include(${QT_USE_FILE})
275 #===============================================================================
276 #= Global Definitions
277 #-------------------------------------------------------------------------------
279 add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS)
280 add_definitions(-D__STDC_LIMIT_MACROS)
281 add_definitions(-Wall -Wextra)
282 add_definitions(-std=c++11)
285 add_definitions(-DENABLE_DECODE)
288 if(NOT DISABLE_WERROR)
289 add_definitions(-Werror)
293 add_definitions(-DENABLE_SIGNALS)
296 #===============================================================================
297 #= Global Include Directories
298 #-------------------------------------------------------------------------------
301 ${CMAKE_CURRENT_BINARY_DIR}
302 ${CMAKE_CURRENT_SOURCE_DIR}
303 ${Boost_INCLUDE_DIRS}
307 if(STATIC_PKGDEPS_LIBS)
308 include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS})
310 include_directories(${PKGDEPS_INCLUDE_DIRS})
313 #===============================================================================
314 #= Linker Configuration
315 #-------------------------------------------------------------------------------
317 link_directories(${Boost_LIBRARY_DIRS})
319 set(PULSEVIEW_LINK_LIBS
322 ${CMAKE_THREAD_LIBS_INIT}
325 if(STATIC_PKGDEPS_LIBS)
326 link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
327 list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES})
329 # Workaround for a MinGW linking issue.
330 list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2")
333 link_directories(${PKGDEPS_LIBRARY_DIRS})
334 list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
338 # On Windows we need to statically link the libqsvg imageformat
339 # plugin (and the QtSvg component) for SVG graphics/icons to work.
340 add_definitions(-DQT_STATICPLUGIN)
341 link_directories("${QT_PLUGINS_DIR}/imageformats")
342 list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg")
343 list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY})
347 list(APPEND PULSEVIEW_LINK_LIBS "-llog")
351 add_library(${PROJECT_NAME} SHARED
353 ${pulseview_HEADERS_MOC}
354 ${pulseview_FORMS_HEADERS}
355 ${pulseview_RESOURCES_RCC}
358 add_executable(${PROJECT_NAME}
360 ${pulseview_HEADERS_MOC}
361 ${pulseview_FORMS_HEADERS}
362 ${pulseview_RESOURCES_RCC}
366 target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})
369 # Pass -mwindows so that no "DOS box" opens when PulseView is started.
370 set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows")
375 cotire(${PROJECT_NAME})
378 #===============================================================================
380 #-------------------------------------------------------------------------------
382 # Install the executable.
383 install(TARGETS ${PROJECT_NAME} DESTINATION bin/)
385 # Install the manpage.
386 install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
388 #===============================================================================
389 #= Packaging (handled by CPack)
390 #-------------------------------------------------------------------------------
392 set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR})
393 set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR})
394 set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO})
395 set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
396 set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
397 set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git")
398 set(CPACK_SOURCE_PACKAGE_FILE_NAME
399 "${CMAKE_PROJECT_NAME}-${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}")
400 set(CPACK_SOURCE_GENERATOR "TGZ")
404 #===============================================================================
406 #-------------------------------------------------------------------------------
409 add_subdirectory(test)
411 add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/pulseview-test)