86 lines
2.1 KiB
Diff
86 lines
2.1 KiB
Diff
|
commit 7407665b4948cb9eee6e3d89daf65a23e7977d34
|
||
|
Author: Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||
|
Date: Sat Jun 21 06:04:09 2014 +0100
|
||
|
|
||
|
Add Qt5 support.
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index f298def..e65aa5e 100644
|
||
|
--- CMakeLists.txt
|
||
|
+++ CMakeLists.txt
|
||
|
@@ -2,8 +2,22 @@ project(compton-conf)
|
||
|
|
||
|
cmake_minimum_required(VERSION 2.8.6)
|
||
|
|
||
|
-# Qt
|
||
|
-find_package(Qt4 REQUIRED QtCore QtGui QtDbus)
|
||
|
+# Support Qt5
|
||
|
+option(USE_QT5 "Build with Qt5." $ENV{USE_QT5})
|
||
|
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||
|
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||
|
+set(CMAKE_AUTOMOC ON)
|
||
|
+if(USE_QT5)
|
||
|
+ cmake_minimum_required(VERSION 2.8.11)
|
||
|
+ find_package(Qt5Widgets REQUIRED)
|
||
|
+ find_package(Qt5DBus REQUIRED)
|
||
|
+ find_package(Qt5LinguistTools REQUIRED QUIET)
|
||
|
+ message(STATUS "Building with Qt${Qt5Core_VERSION_STRING}")
|
||
|
+else()
|
||
|
+ find_package(Qt4 REQUIRED QtCore QtGui QtDbus)
|
||
|
+ include(${QT_USE_FILE})
|
||
|
+ message(STATUS "Building with Qt${QTVERSION}")
|
||
|
+endif()
|
||
|
|
||
|
# libconfig using pkg-config
|
||
|
find_package(PkgConfig REQUIRED)
|
||
|
@@ -15,14 +29,20 @@ include(GNUInstallDirs REQUIRED)
|
||
|
|
||
|
set(CMAKE_CXX_FLAGS "-DQT_NO_KEYWORDS -fno-exceptions")
|
||
|
|
||
|
+if(USE_QT5)
|
||
|
+ set(QTX_INCLUDE_DIRS "")
|
||
|
+ set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus)
|
||
|
+else()
|
||
|
+ set(QTX_INCLUDE_DIRS ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_DIR})
|
||
|
+ set(QTX_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY})
|
||
|
+endif()
|
||
|
+
|
||
|
include_directories(
|
||
|
- ${QT_INCLUDES}
|
||
|
+ ${QTX_INCLUDE_DIRS}
|
||
|
${LIBCONFIG_INCLUDE_DIRS}
|
||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||
|
)
|
||
|
|
||
|
-set(CMAKE_AUTOMOC TRUE)
|
||
|
-
|
||
|
set(compton-conf_SRCS
|
||
|
maindialog.cpp
|
||
|
compton-conf.cpp
|
||
|
@@ -32,9 +52,11 @@ set(compton-conf_UIS
|
||
|
maindialog.ui
|
||
|
)
|
||
|
|
||
|
-qt4_wrap_ui(compton-conf_UI_H
|
||
|
- ${compton-conf_UIS}
|
||
|
-)
|
||
|
+if(USE_QT5)
|
||
|
+ qt5_wrap_ui(compton-conf_UI_H ${compton-conf_UIS})
|
||
|
+else()
|
||
|
+ qt4_wrap_ui(compton-conf_UI_H ${compton-conf_UIS})
|
||
|
+endif()
|
||
|
|
||
|
add_definitions(
|
||
|
-DCOMPTON_CONF_DATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/compton-conf"
|
||
|
@@ -46,9 +68,7 @@ add_executable(compton-conf
|
||
|
)
|
||
|
|
||
|
target_link_libraries(compton-conf
|
||
|
- ${QT_QTCORE_LIBRARY}
|
||
|
- ${QT_QTGUI_LIBRARY}
|
||
|
- ${QT_QTDBUS_LIBRARY}
|
||
|
+ ${QTX_LIBRARIES}
|
||
|
${LIBCONFIG_LIBRARIES}
|
||
|
)
|
||
|
|