##
## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
## Copyright (C) 2012-2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+## Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
cmake_minimum_required(VERSION 2.8.12)
-include(GNUInstallDirs)
+project(pulseview C CXX)
-project(pulseview)
+include(GNUInstallDirs)
# Let AUTOMOC and AUTOUIC process GENERATED files.
if(POLICY CMP0071)
option(ENABLE_FLOW "Build with libsigrokflow" FALSE)
option(ENABLE_TESTS "Enable unit tests" FALSE)
option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE)
+option(ENABLE_TS_UPDATE "Update .ts source files (Qt l10n)" FALSE)
if(WIN32)
# On Windows/MinGW we need to statically link to libraries.
#= Dependencies
#-------------------------------------------------------------------------------
+include(CheckCSourceCompiles)
+include(CheckCXXCompilerFlag)
+include(CheckCXXSourceCompiles)
+include(CMakePushCheckState)
+include(memaccess)
+
+find_package(PkgConfig)
+
+if(CMAKE_VERSION VERSION_EQUAL "3.8.0" OR CMAKE_VERSION VERSION_GREATER "3.8.0")
+ check_cxx_compiler_flag("-std=c++17" HAVE_STD_CXX_17)
+ check_cxx_compiler_flag("-std=c++14" HAVE_STD_CXX_14)
+ check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX_11)
+ if(HAVE_STD_CXX_17)
+ message(STATUS "Using C++17 for the application build")
+ set(CMAKE_CXX_STANDARD 17)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++17")
+ elseif(HAVE_STD_CXX_14)
+ message(STATUS "Using C++14 for the application build")
+ set(CMAKE_CXX_STANDARD 14)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++14")
+ elseif(HAVE_STD_CXX_11)
+ message(STATUS "Using C++11 for the application build")
+ set(CMAKE_CXX_STANDARD 11)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++11")
+ else()
+ message(FATAL_ERROR "Need modern C++, at least language standard 11")
+ endif()
+else()
+ check_cxx_compiler_flag("-std=c++14" HAVE_STD_CXX_14)
+ check_cxx_compiler_flag("-std=c++11" HAVE_STD_CXX_11)
+ if(HAVE_STD_CXX_14)
+ message(STATUS "Using C++14 for the application build")
+ set(CMAKE_CXX_STANDARD 14)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++14")
+ elseif(HAVE_STD_CXX_11)
+ message(STATUS "Using C++11 for the application build")
+ set(CMAKE_CXX_STANDARD 11)
+ set(REQUIRED_STD_CXX_FLAGS "-std=c++11")
+ else()
+ message(FATAL_ERROR "Need modern C++, at least language standard 11")
+ endif()
+endif()
+
list(APPEND PKGDEPS glib-2.0>=2.28.0)
-list(APPEND PKGDEPS glibmm-2.4>=2.28.0)
+
+# Try to find the prefered glibmm-2.4. If not found then add glibmm-2.68
+# to the dependency list.
+pkg_check_modules(GLIBMM_2_4 glibmm-2.4>=2.28.0)
+if(GLIBMM_2_4_FOUND)
+ list(APPEND PKGDEPS glibmm-2.4>=2.28.0)
+else()
+ list(APPEND PKGDEPS glibmm-2.68>=2.68.0)
+endif()
if(ENABLE_FLOW)
list(APPEND PKGDEPS gstreamermm-1.0>=1.8.0)
list(APPEND PKGDEPS libsigrokflow>=0.1.0)
endif()
-set(LIBSR_CXX_BINDING "libsigrokcxx>=0.5.1")
+set(LIBSR_CXX_BINDING "libsigrokcxx>=0.5.2")
list(APPEND PKGDEPS "${LIBSR_CXX_BINDING}")
if(ENABLE_DECODE)
list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0)
endif()
-find_package(PkgConfig)
pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING})
if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION)
message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)")
set(CMAKE_AUTOMOC TRUE)
-find_package(Qt5 5.3 COMPONENTS Core Gui Widgets Svg REQUIRED)
-
-message(STATUS "Qt version: ${Qt5_VERSION}")
+# Check for Qt5, and check for Qt6 if Qt5 is not found.
+set(QT_COMPONENTS Core Gui LinguistTools Widgets Svg)
+find_package(Qt5 5.3 QUIET COMPONENTS Core)
+if(Qt5_FOUND)
+ find_package(Qt5 5.3 COMPONENTS ${QT_COMPONENTS} REQUIRED)
+ message(STATUS "Qt version: ${Qt5_VERSION}")
+else()
+ find_package(Qt6 6.2 COMPONENTS ${QT_COMPONENTS} REQUIRED)
+ message(STATUS "Qt version: ${Qt6_VERSION}")
+endif()
if(WIN32)
- # MXE workaround: Use pkg-config to find Qt5 libs.
+ # MXE workaround: Use pkg-config to find Qt5 and Qt6 libs.
# https://github.com/mxe/mxe/issues/1642
# Not required (and doesn't work) on MSYS2.
if(NOT DEFINED ENV{MSYSTEM})
- pkg_check_modules(QT5ALL REQUIRED Qt5Widgets>=5.3 Qt5Gui>=5.3 Qt5Svg>=5.3)
+ if(Qt5_FOUND)
+ pkg_check_modules(QT5ALL REQUIRED Qt5Widgets>=5.3 Qt5Gui>=5.3 Qt5Svg>=5.3)
+ else()
+ pkg_check_modules(QT6ALL REQUIRED Qt6Widgets>=6.2 Qt6Gui>=6.2 Qt6Svg>=6.2)
+ endif()
endif()
endif()
-set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
+if(Qt5_FOUND)
+ set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
+else()
+ set(QT_LIBRARIES Qt6::Gui Qt6::Widgets Qt6::Svg)
+endif()
set(BOOSTCOMPS filesystem serialization system)
if(ENABLE_TESTS)
endif()
if(ENABLE_STACKTRACE)
+ include(FindBacktrace)
+ if (Backtrace_FOUND)
+ set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
+ list(APPEND BOOSTCOMPS stacktrace_backtrace)
+ else()
+ set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp")
+ list(APPEND BOOSTCOMPS stacktrace_basic)
+ endif()
find_package(Boost 1.65.1 COMPONENTS ${BOOSTCOMPS} REQUIRED)
else()
find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED)
# Helper for checking for atomics
function(check_working_cxx_atomics varname additional_lib)
- include(CheckCXXSourceCompiles)
- include(CMakePushCheckState)
- cmake_push_check_state()
- set(CMAKE_REQUIRED_FLAGS "-std=c++11")
- set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}")
- set(CMAKE_REQUIRED_QUIET 1)
- CHECK_CXX_SOURCE_COMPILES("
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "${REQUIRED_STD_CXX_FLAGS}")
+ set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}")
+ set(CMAKE_REQUIRED_QUIET 1)
+ CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
- return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst);
+ return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst);
}
" ${varname})
- cmake_pop_check_state()
+ cmake_pop_check_state()
endfunction(check_working_cxx_atomics)
# First check if atomics work without the library.
# If not, check if the library exists, and atomics work with it.
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB "")
if(HAVE_CXX_ATOMICS_WITHOUT_LIB)
- message(STATUS "Atomics provided by the C-library - yes")
+ message(STATUS "Atomics provided by the C-library - yes")
else()
- message(STATUS "Atomics provided by the C-library - no")
- find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib)
- if(LIBATOMIC_LIBRARY)
- check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}")
- if (HAVE_CXX_ATOMICS_WITH_LIB)
- message(STATUS "Atomics provided by libatomic - yes")
- else()
- message(STATUS "Atomics provided by libatomic - no")
- message(FATAL_ERROR "Compiler must support std::atomic!")
- endif()
- else()
- message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.")
- endif()
+ message(STATUS "Atomics provided by the C-library - no")
+ find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib)
+ if(LIBATOMIC_LIBRARY)
+ check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}")
+ if (HAVE_CXX_ATOMICS_WITH_LIB)
+ message(STATUS "Atomics provided by libatomic - yes")
+ else()
+ message(STATUS "Atomics provided by libatomic - no")
+ message(FATAL_ERROR "Compiler must support std::atomic!")
+ endif()
+ else()
+ message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.")
+ endif()
+endif()
+
+# Check availability of features which depend on library versions.
+# TODO Ideally use check_symbol_exists() instead, reduce boilerplate.
+if(ENABLE_DECODE)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_INCLUDES "${PKGDEPS_INCLUDE_DIRS}")
+ set(CMAKE_REQUIRED_LIBRARIES "sigrokdecode")
+ foreach (LPATH ${PKGDEPS_LIBRARY_DIRS})
+ list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-L${LPATH}")
+ endforeach ()
+ check_c_source_compiles("
+ #include <libsigrokdecode/libsigrokdecode.h>
+ int main(int argc, char *argv[])
+ {
+ (void)argc;
+ (void)argv;
+ return srd_session_send_eof(NULL);
+ }
+ " HAVE_SRD_SESSION_SEND_EOF)
+ cmake_pop_check_state()
endif()
#===============================================================================
#= System Introspection
#-------------------------------------------------------------------------------
-include(memaccess)
memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS)
#===============================================================================
set(PV_TITLE PulseView)
set(PV_VERSION_STRING "0.5.0")
-set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION})
+if(GLIBMM_2_4_FOUND)
+ set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION})
+else()
+ set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.68_VERSION})
+endif()
include(GetGitRevisionDescription)
pv/globalsettings.cpp
pv/logging.cpp
pv/mainwindow.cpp
+ pv/metadata_obj.cpp
pv/session.cpp
pv/storesession.cpp
pv/util.cpp
pv/data/analogsegment.cpp
pv/data/logic.cpp
pv/data/logicsegment.cpp
+ pv/data/mathsignal.cpp
pv/data/signalbase.cpp
pv/data/signaldata.cpp
pv/data/segment.cpp
pv/views/trace/cursorpair.cpp
pv/views/trace/flag.cpp
pv/views/trace/header.cpp
+ pv/views/trace/mathsignal.cpp
pv/views/trace/marginwidget.cpp
pv/views/trace/logicsignal.cpp
pv/views/trace/ruler.cpp
pv/widgets/colorpopup.cpp
pv/widgets/devicetoolbutton.cpp
pv/widgets/exportmenu.cpp
+ pv/widgets/flowlayout.cpp
pv/widgets/importmenu.cpp
pv/widgets/popup.cpp
pv/widgets/popuptoolbutton.cpp
# This list includes only QObject derived class headers.
set(pulseview_HEADERS
+ pv/exprtk.hpp
pv/logging.hpp
pv/globalsettings.hpp
pv/mainwindow.hpp
+ pv/metadata_obj.hpp
pv/session.hpp
pv/storesession.hpp
pv/binding/device.hpp
pv/data/analogsegment.hpp
pv/data/logic.hpp
pv/data/logicsegment.hpp
+ pv/data/mathsignal.hpp
pv/data/signalbase.hpp
pv/dialogs/connect.hpp
pv/dialogs/inputoutputoptions.hpp
pv/views/trace/flag.hpp
pv/views/trace/header.hpp
pv/views/trace/logicsignal.hpp
+ pv/views/trace/mathsignal.hpp
pv/views/trace/marginwidget.hpp
pv/views/trace/ruler.hpp
pv/views/trace/signal.hpp
pv/widgets/colorpopup.hpp
pv/widgets/devicetoolbutton.hpp
pv/widgets/exportmenu.hpp
+ pv/widgets/flowlayout.hpp
pv/widgets/importmenu.hpp
pv/widgets/popup.hpp
pv/widgets/popuptoolbutton.hpp
pv/subwindows/decoder_selector/item.cpp
pv/subwindows/decoder_selector/model.cpp
pv/subwindows/decoder_selector/subwindow.cpp
- pv/views/decoder_output/view.cpp
- pv/views/decoder_output/QHexView.cpp
+ pv/views/decoder_binary/view.cpp
+ pv/views/decoder_binary/QHexView.cpp
+ pv/views/tabular_decoder/model.cpp
+ pv/views/tabular_decoder/view.cpp
pv/views/trace/decodetrace.cpp
pv/widgets/decodergroupbox.cpp
pv/widgets/decodermenu.cpp
list(APPEND pulseview_HEADERS
pv/data/decodesignal.hpp
pv/subwindows/decoder_selector/subwindow.hpp
- pv/views/decoder_output/view.hpp
- pv/views/decoder_output/QHexView.hpp
+ pv/views/decoder_binary/view.hpp
+ pv/views/decoder_binary/QHexView.hpp
+ pv/views/tabular_decoder/view.hpp
pv/views/trace/decodetrace.hpp
pv/widgets/decodergroupbox.hpp
pv/widgets/decodermenu.hpp
)
endif()
-qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
+if(Qt5_FOUND)
+ qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
+else()
+ qt6_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
+endif()
+
+#===============================================================================
+#= Translations
+#-------------------------------------------------------------------------------
+
+file(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/l10n/*.ts)
+set_property(SOURCE ${TS_FILES} PROPERTY OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/l10n)
+if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+ configure_file("translations.qrc" "translations.qrc" COPYONLY)
+endif ()
+
+if(Qt5_FOUND)
+ qt5_add_translation(QM_FILES ${TS_FILES})
+ qt5_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc)
+ if (ENABLE_TS_UPDATE)
+ qt5_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES})
+ endif ()
+else()
+ qt6_add_translation(QM_FILES ${TS_FILES})
+ qt6_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc)
+ if (ENABLE_TS_UPDATE)
+ qt6_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES})
+ endif ()
+endif()
#===============================================================================
#= Global Definitions
add_definitions(-DQT_NO_KEYWORDS)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-Wall -Wextra)
-add_definitions(-std=c++11)
+add_definitions(${REQUIRED_STD_CXX_FLAGS})
+
add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1)
+if(WIN32)
+ add_definitions(-Wa,-mbig-obj -O3)
+endif()
if(ENABLE_FLOW)
add_definitions(-DENABLE_FLOW)
endif()
if(ENABLE_STACKTRACE)
- add_definitions(-DENABLE_STACKTRACE)
+ add_definitions(-DENABLE_STACKTRACE -no-pie -fno-pie)
+ if (Backtrace_FOUND)
+ add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE)
+ endif()
endif()
#===============================================================================
# We also need QWindowsIntegrationPlugin, Qt5PlatformSupport (only for
# Qt < 5.8.0), and all Qt libs and their dependencies.
add_definitions(-DQT_STATICPLUGIN)
- list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
- list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
- if(Qt5Gui_VERSION VERSION_LESS 5.8.0)
- list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport)
+ if(Qt5_FOUND)
+ list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
+ list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
+ if(Qt5Gui_VERSION VERSION_LESS 5.8.0)
+ list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport)
+ endif()
+ list(APPEND PULSEVIEW_LINK_LIBS ${QT5ALL_LDFLAGS})
+ else()
+ list(APPEND PULSEVIEW_LINK_LIBS Qt6::QSvgPlugin)
+ list(APPEND PULSEVIEW_LINK_LIBS Qt6::QWindowsIntegrationPlugin)
+ list(APPEND PULSEVIEW_LINK_LIBS ${QT6ALL_LDFLAGS})
endif()
- list(APPEND PULSEVIEW_LINK_LIBS ${QT5ALL_LDFLAGS})
endif()
if(ENABLE_STACKTRACE)
- # Needed to resolve dladdr.
- list(APPEND PULSEVIEW_LINK_LIBS "-ldl")
+ list(APPEND PULSEVIEW_LINK_LIBS ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
+ link_libraries("-no-pie -fno-pie")
endif()
if(ANDROID)
list(APPEND PULSEVIEW_LINK_LIBS "-llog")
endif()
+set(INPUT_FILES_LIST ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC} ${QM_FILES})
if(ANDROID)
- add_library(${PROJECT_NAME} SHARED ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC})
+ add_library(${PROJECT_NAME} SHARED ${INPUT_FILES_LIST})
else()
- add_executable(${PROJECT_NAME} ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC})
+ add_executable(${PROJECT_NAME} ${INPUT_FILES_LIST})
endif()
target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})