]> sigrok.org Git - pulseview.git/commitdiff
Simplify Qt5 setup, require cmake >= 2.8.12.
authorUwe Hermann <redacted>
Tue, 28 Mar 2017 20:54:27 +0000 (22:54 +0200)
committerUwe Hermann <redacted>
Tue, 28 Mar 2017 23:54:42 +0000 (01:54 +0200)
We now require cmake >= 2.8.12 (released 2013 or so, should be available
pretty much anywhere by now) which further simplifies the Qt5 setup.

Details:
https://doc.qt.io/qt-5/cmake-manual.html
https://cmake.org/cmake/help/v3.7/prop_tgt/AUTOMOC.html
https://cmake.org/cmake/help/v3.7/prop_tgt/AUTORCC.html

CMakeLists.txt
INSTALL
test/CMakeLists.txt

index 0d9b455f2316548c71507a746fe95c4e241601e9..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)
 
@@ -68,10 +68,10 @@ endif()
 find_package(PkgConfig)
 pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
 
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Gui REQUIRED)
-find_package(Qt5Svg REQUIRED)
+set(CMAKE_AUTOMOC TRUE)
+set(CMAKE_AUTORCC TRUE)
+
+find_package(Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
 
 if(WIN32)
        # MXE workaround: Use pkg-config to find Qt5 libs.
@@ -79,10 +79,7 @@ if(WIN32)
        pkg_check_modules(QT5ALL REQUIRED Qt5Widgets Qt5Gui Qt5Svg)
 endif()
 
-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})
 
 set(BOOSTCOMPS filesystem serialization system)
 if(ENABLE_TESTS)
@@ -261,6 +258,7 @@ 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.
@@ -322,10 +320,6 @@ set(pulseview_HEADERS
        pv/widgets/wellarray.hpp
 )
 
-set(pulseview_RESOURCES
-       pulseview.qrc
-)
-
 if(ENABLE_SIGNALS)
        list(APPEND pulseview_SOURCES signalhandler.cpp)
        list(APPEND pulseview_HEADERS signalhandler.hpp)
@@ -366,14 +360,11 @@ if(ANDROID)
        )
 endif()
 
-qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
-qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
-
 #===============================================================================
 #= 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)
@@ -399,7 +390,6 @@ include_directories(
        ${CMAKE_CURRENT_BINARY_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${Boost_INCLUDE_DIRS}
-       ${QT_INCLUDE_DIRS}
 )
 
 if(STATIC_PKGDEPS_LIBS)
@@ -445,17 +435,9 @@ if(ANDROID)
 endif()
 
 if(ANDROID)
-add_library(${PROJECT_NAME} SHARED
-       ${pulseview_SOURCES}
-       ${pulseview_HEADERS_MOC}
-       ${pulseview_RESOURCES_RCC}
-)
+       add_library(${PROJECT_NAME} SHARED ${pulseview_SOURCES})
 else()
-add_executable(${PROJECT_NAME}
-       ${pulseview_SOURCES}
-       ${pulseview_HEADERS_MOC}
-       ${pulseview_RESOURCES_RCC}
-)
+       add_executable(${PROJECT_NAME} ${pulseview_SOURCES})
 endif()
 
 target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})
diff --git a/INSTALL b/INSTALL
index 075b18cedab5aa09a2ecf575409202c9f5418905..9f95554be9de7973b7b2fd74e394b8544ac378fa 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -12,7 +12,7 @@ Requirements
  - make
  - libtool (only needed when building from git)
  - pkg-config >= 0.22
- - cmake >= 2.8.6
+ - cmake >= 2.8.12
  - libglib >= 2.28.0
  - glibmm-2.4 (>= 2.28.0)
  - Qt5 (including the following components):
index 3a1a3d29a4806db2ada4f28e29bf4de955889137..09678e84e87ae87788fbeb1c41ba9a31638a5ec4 100644 (file)
@@ -176,8 +176,6 @@ if(ENABLE_DECODE)
        )
 endif()
 
-qt5_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS})
-
 # On MinGW we need to use static linking.
 if(NOT WIN32)
        add_definitions(-DBOOST_TEST_DYN_LINK)