Add a tooltip for the "Show/hide decoder trace" icon.
[pulseview.git] / CMakeLists.txt
index ee58ce2cd6b335f00e272dc172ee79f50ab2b2d5..17e28827aafe3f43e13b99eb8e9e379675e89a6d 100644 (file)
@@ -18,7 +18,7 @@
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ##
 
-cmake_minimum_required(VERSION 2.8.6)
+cmake_minimum_required(VERSION 2.8.12)
 
 include(GNUInstallDirs)
 
@@ -35,21 +35,12 @@ option(ENABLE_SIGNALS "Build with UNIX signals" TRUE)
 option(ENABLE_DECODE "Build with libsigrokdecode" TRUE)
 option(ENABLE_TESTS "Enable unit tests" TRUE)
 option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE)
-option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE)
 
 if(WIN32)
        # On Windows/MinGW we need to statically link to libraries.
        # This option is user configurable, but enable it by default on win32.
        set(STATIC_PKGDEPS_LIBS TRUE)
 
-       # For boost-thread we need two additional settings on win32:
-       set(Boost_USE_STATIC_LIBS ON)
-       add_definitions(-DBOOST_THREAD_USE_LIB)
-
-       # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'.
-       # The library is named libboost_thread_win32* (not libboost_thread*).
-       set(Boost_THREADAPI win32)
-
        # Windows does not support UNIX signals.
        set(ENABLE_SIGNALS FALSE)
 endif()
@@ -77,27 +68,20 @@ endif()
 find_package(PkgConfig)
 pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
 
-if(FORCE_QT4)
-       set(Qt5Core_FOUND FALSE)
-else()
-       find_package(Qt5Core QUIET)
-endif()
+set(CMAKE_AUTOMOC TRUE)
+set(CMAKE_AUTORCC TRUE)
 
-if(Qt5Core_FOUND)
-       message("-- Using Qt5")
-       find_package(Qt5Widgets REQUIRED)
-       find_package(Qt5Gui REQUIRED)
-       find_package(Qt5Svg REQUIRED)
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
-       set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
-       set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
-       add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
-else()
-       find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac)
-       find_package(Qt4 REQUIRED QtCore QtGui QtSvg)
+find_package(Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
+
+if(WIN32)
+       # MXE workaround: Use pkg-config to find Qt5 libs.
+       # https://github.com/mxe/mxe/issues/1642
+       pkg_check_modules(QT5ALL REQUIRED Qt5Widgets Qt5Gui Qt5Svg)
 endif()
 
-set(BOOSTCOMPS filesystem serialization system thread)
+set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Svg)
+
+set(BOOSTCOMPS filesystem serialization system)
 if(ENABLE_TESTS)
        list(APPEND BOOSTCOMPS unit_test_framework)
 endif()
@@ -107,7 +91,6 @@ find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED)
 # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
 find_package(Threads REQUIRED)
 
-
 # Check for explicit link against libatomic
 #
 # Depending on the toolchain, linking a program using atomic functions may need
@@ -205,6 +188,7 @@ set(pulseview_SOURCES
        main.cpp
        pv/application.cpp
        pv/devicemanager.cpp
+       pv/globalsettings.cpp
        pv/mainwindow.cpp
        pv/session.cpp
        pv/storesession.cpp
@@ -224,9 +208,9 @@ set(pulseview_SOURCES
        pv/devices/hardwaredevice.cpp
        pv/devices/inputfile.cpp
        pv/devices/sessionfile.cpp
-       pv/dialogs/about.cpp
        pv/dialogs/connect.cpp
        pv/dialogs/inputoutputoptions.cpp
+       pv/dialogs/settings.cpp
        pv/dialogs/storeprogress.cpp
        pv/popups/deviceoptions.cpp
        pv/popups/channels.cpp
@@ -274,18 +258,24 @@ set(pulseview_SOURCES
        pv/widgets/sweeptimingwidget.cpp
        pv/widgets/timestampspinbox.cpp
        pv/widgets/wellarray.cpp
+       pulseview.qrc
 )
 
 # This list includes only QObject derived class headers.
 set(pulseview_HEADERS
+       pv/globalsettings.hpp
        pv/mainwindow.hpp
        pv/session.hpp
        pv/storesession.hpp
        pv/binding/device.hpp
+       pv/data/analog.hpp
+       pv/data/analogsegment.hpp
+       pv/data/logic.hpp
+       pv/data/logicsegment.hpp
        pv/data/signalbase.hpp
-       pv/dialogs/about.hpp
        pv/dialogs/connect.hpp
        pv/dialogs/inputoutputoptions.hpp
+       pv/dialogs/settings.hpp
        pv/dialogs/storeprogress.hpp
        pv/popups/channels.hpp
        pv/popups/deviceoptions.hpp
@@ -330,14 +320,6 @@ set(pulseview_HEADERS
        pv/widgets/wellarray.hpp
 )
 
-set(pulseview_FORMS
-       pv/dialogs/about.ui
-)
-
-set(pulseview_RESOURCES
-       pulseview.qrc
-)
-
 if(ENABLE_SIGNALS)
        list(APPEND pulseview_SOURCES signalhandler.cpp)
        list(APPEND pulseview_HEADERS signalhandler.hpp)
@@ -378,25 +360,11 @@ if(ANDROID)
        )
 endif()
 
-if(Qt5Core_FOUND)
-       qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
-       qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
-       qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
-else()
-       # Workaround for QTBUG-22829: -DBOOST_NEXT_PRIOR_HPP_INCLUDED.
-       # https://bugreports.qt.io/browse/QTBUG-22829
-       qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}
-               OPTIONS -DBOOST_NEXT_PRIOR_HPP_INCLUDED)
-       qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
-       qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
-       include(${QT_USE_FILE})
-endif()
-
 #===============================================================================
 #= Global Definitions
 #-------------------------------------------------------------------------------
 
-add_definitions(${QT_DEFINITIONS} -DQT_NO_KEYWORDS)
+add_definitions(-DQT_NO_KEYWORDS)
 add_definitions(-D__STDC_LIMIT_MACROS)
 add_definitions(-Wall -Wextra)
 add_definitions(-std=c++11)
@@ -422,7 +390,6 @@ include_directories(
        ${CMAKE_CURRENT_BINARY_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${Boost_INCLUDE_DIRS}
-       ${QT_INCLUDE_DIRS}
 )
 
 if(STATIC_PKGDEPS_LIBS)
@@ -446,11 +413,7 @@ set(PULSEVIEW_LINK_LIBS
 
 if(STATIC_PKGDEPS_LIBS)
        link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
-       list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES})
-if(WIN32)
-       # Workaround for a MinGW linking issue.
-       list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2")
-endif()
+       list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LDFLAGS})
 else()
        link_directories(${PKGDEPS_LIBRARY_DIRS})
        list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
@@ -459,10 +422,12 @@ endif()
 if(WIN32)
        # On Windows we need to statically link the libqsvg imageformat
        # plugin (and the QtSvg component) for SVG graphics/icons to work.
+       # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport, and all
+       # Qt libs and their dependencies.
        add_definitions(-DQT_STATICPLUGIN)
-       link_directories("${QT_PLUGINS_DIR}/imageformats")
-       list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg")
-       list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY})
+       list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
+       list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
+       list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport ${QT5ALL_LDFLAGS})
 endif()
 
 if(ANDROID)
@@ -470,19 +435,9 @@ if(ANDROID)
 endif()
 
 if(ANDROID)
-add_library(${PROJECT_NAME} SHARED
-       ${pulseview_SOURCES}
-       ${pulseview_HEADERS_MOC}
-       ${pulseview_FORMS_HEADERS}
-       ${pulseview_RESOURCES_RCC}
-)
+       add_library(${PROJECT_NAME} SHARED ${pulseview_SOURCES})
 else()
-add_executable(${PROJECT_NAME}
-       ${pulseview_SOURCES}
-       ${pulseview_HEADERS_MOC}
-       ${pulseview_FORMS_HEADERS}
-       ${pulseview_RESOURCES_RCC}
-)
+       add_executable(${PROJECT_NAME} ${pulseview_SOURCES})
 endif()
 
 target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})