|
Rex Dieter |
e5f144c |
From d3feea63092179734cb9d5e92b4ffecfb411364b Mon Sep 17 00:00:00 2001
|
|
Rex Dieter |
e5f144c |
From: Montel Laurent <montel@kde.org>
|
|
Rex Dieter |
e5f144c |
Date: Sun, 20 Apr 2014 07:57:51 +0200
|
|
Rex Dieter |
e5f144c |
Subject: [PATCH 2/9] Allow to build with qt5 and qt4
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
---
|
|
Rex Dieter |
e5f144c |
CMakeLists.txt | 31 ++++++++-
|
|
Rex Dieter |
e5f144c |
cmake/modules/ECMQt4To5Porting.cmake | 119 +++++++++++++++++++++++++++++++++++
|
|
Rex Dieter |
e5f144c |
lib/prison/CMakeLists.txt | 2 +-
|
|
Rex Dieter |
e5f144c |
lib/prison/barcodewidget.cpp | 2 +
|
|
Rex Dieter |
e5f144c |
testapp/CMakeLists.txt | 5 +-
|
|
Rex Dieter |
e5f144c |
tools/CMakeLists.txt | 4 +-
|
|
Rex Dieter |
e5f144c |
6 files changed, 155 insertions(+), 8 deletions(-)
|
|
Rex Dieter |
e5f144c |
create mode 100644 cmake/modules/ECMQt4To5Porting.cmake
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
index 479c563..3c26bb1 100644
|
|
Rex Dieter |
e5f144c |
--- a/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
+++ b/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
|
|
Rex Dieter |
e5f144c |
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
|
Rex Dieter |
e5f144c |
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
-find_package(Qt4 REQUIRED)
|
|
Rex Dieter |
e5f144c |
find_package(QRencode REQUIRED)
|
|
Rex Dieter |
e5f144c |
find_package(Dmtx REQUIRED)
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
@@ -12,9 +11,39 @@ find_package(Dmtx REQUIRED)
|
|
Rex Dieter |
e5f144c |
set(CMAKE_AUTOMOC ON)
|
|
Rex Dieter |
e5f144c |
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
+option(QT5_BUILD "Build Akonadi using the Qt5 framework" FALSE)
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
include_directories(${CMAKE_SOURCE_DIR}/lib ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} )
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
+#### Qt 4 and 5 ####
|
|
Rex Dieter |
e5f144c |
+if(QT5_BUILD)
|
|
Rex Dieter |
e5f144c |
+ find_package(Qt5Core REQUIRED)
|
|
Rex Dieter |
e5f144c |
+ find_package(Qt5Gui REQUIRED)
|
|
Rex Dieter |
e5f144c |
+ find_package(Qt5Widgets REQUIRED)
|
|
Rex Dieter |
e5f144c |
+ find_package(Qt5Test REQUIRED)
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+ include("cmake/modules/ECMQt4To5Porting.cmake")
|
|
Rex Dieter |
e5f144c |
+ include_directories(${QT_INCLUDES}) # TODO: Port away from this.
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+ if(CMAKE_VERSION VERSION_LESS 2.8.9)
|
|
Rex Dieter |
e5f144c |
+ message(FATAL_ERROR "Akonadi Qt 5 build requires at least CMake version 2.8.9")
|
|
Rex Dieter |
e5f144c |
+ endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+ if (Qt5_POSITION_INDEPENDENT_CODE)
|
|
Rex Dieter |
e5f144c |
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
Rex Dieter |
e5f144c |
+ endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+ set(QT_QTTEST_LIBRARIES Qt5::Test)
|
|
Rex Dieter |
e5f144c |
+else()
|
|
Rex Dieter |
e5f144c |
+ set(QT_USE_IMPORTED_TARGETS TRUE) # Qt 4 only
|
|
Rex Dieter |
e5f144c |
+ set(QT_MIN_VERSION 4.8.0) # Qt 4 only
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+ find_package(Qt4 REQUIRED)
|
|
Rex Dieter |
e5f144c |
+ include(${QT_USE_FILE})
|
|
Rex Dieter |
e5f144c |
+endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
add_subdirectory(lib)
|
|
Rex Dieter |
e5f144c |
add_subdirectory(testapp)
|
|
Rex Dieter |
e5f144c |
diff --git a/cmake/modules/ECMQt4To5Porting.cmake b/cmake/modules/ECMQt4To5Porting.cmake
|
|
Rex Dieter |
e5f144c |
new file mode 100644
|
|
Rex Dieter |
e5f144c |
index 0000000..7d6458a
|
|
Rex Dieter |
e5f144c |
--- /dev/null
|
|
Rex Dieter |
e5f144c |
+++ b/cmake/modules/ECMQt4To5Porting.cmake
|
|
Rex Dieter |
e5f144c |
@@ -0,0 +1,119 @@
|
|
Rex Dieter |
e5f144c |
+#=============================================================================
|
|
Rex Dieter |
e5f144c |
+# Copyright 2005-2011 Kitware, Inc.
|
|
Rex Dieter |
e5f144c |
+# All rights reserved.
|
|
Rex Dieter |
e5f144c |
+#
|
|
Rex Dieter |
e5f144c |
+# Redistribution and use in source and binary forms, with or without
|
|
Rex Dieter |
e5f144c |
+# modification, are permitted provided that the following conditions
|
|
Rex Dieter |
e5f144c |
+# are met:
|
|
Rex Dieter |
e5f144c |
+#
|
|
Rex Dieter |
e5f144c |
+# * Redistributions of source code must retain the above copyright
|
|
Rex Dieter |
e5f144c |
+# notice, this list of conditions and the following disclaimer.
|
|
Rex Dieter |
e5f144c |
+#
|
|
Rex Dieter |
e5f144c |
+# * Redistributions in binary form must reproduce the above copyright
|
|
Rex Dieter |
e5f144c |
+# notice, this list of conditions and the following disclaimer in the
|
|
Rex Dieter |
e5f144c |
+# documentation and/or other materials provided with the distribution.
|
|
Rex Dieter |
e5f144c |
+#
|
|
Rex Dieter |
e5f144c |
+# * Neither the name of Kitware, Inc. nor the names of its
|
|
Rex Dieter |
e5f144c |
+# contributors may be used to endorse or promote products derived
|
|
Rex Dieter |
e5f144c |
+# from this software without specific prior written permission.
|
|
Rex Dieter |
e5f144c |
+#
|
|
Rex Dieter |
e5f144c |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Rex Dieter |
e5f144c |
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Rex Dieter |
e5f144c |
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Rex Dieter |
e5f144c |
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Rex Dieter |
e5f144c |
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Rex Dieter |
e5f144c |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Rex Dieter |
e5f144c |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Rex Dieter |
e5f144c |
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Rex Dieter |
e5f144c |
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Rex Dieter |
e5f144c |
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Rex Dieter |
e5f144c |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Rex Dieter |
e5f144c |
+#=============================================================================
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+# Portability helpers.
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+set(QT_QTGUI_LIBRARIES
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Gui_LIBRARIES}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Widgets_LIBRARIES}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5PrintSupport_LIBRARIES}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Svg_LIBRARIES}
|
|
Rex Dieter |
e5f144c |
+)
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+set(QT_INCLUDES
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Gui_INCLUDE_DIRS}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Widgets_INCLUDE_DIRS}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5PrintSupport_INCLUDE_DIRS}
|
|
Rex Dieter |
e5f144c |
+ ${Qt5Svg_INCLUDE_DIRS}
|
|
Rex Dieter |
e5f144c |
+)
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+set(_qt_modules
|
|
Rex Dieter |
e5f144c |
+ Core
|
|
Rex Dieter |
e5f144c |
+ Declarative
|
|
Rex Dieter |
e5f144c |
+ Widgets
|
|
Rex Dieter |
e5f144c |
+ Script
|
|
Rex Dieter |
e5f144c |
+ ScriptTools
|
|
Rex Dieter |
e5f144c |
+ DBus
|
|
Rex Dieter |
e5f144c |
+ Network
|
|
Rex Dieter |
e5f144c |
+ Test
|
|
Rex Dieter |
e5f144c |
+ Designer
|
|
Rex Dieter |
e5f144c |
+ Concurrent
|
|
Rex Dieter |
e5f144c |
+ Xml
|
|
Rex Dieter |
e5f144c |
+ UiTools
|
|
Rex Dieter |
e5f144c |
+ WebKit
|
|
Rex Dieter |
e5f144c |
+ Sql
|
|
Rex Dieter |
e5f144c |
+ OpenGL
|
|
Rex Dieter |
e5f144c |
+)
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+foreach(_module ${_qt_modules})
|
|
Rex Dieter |
e5f144c |
+ string(TOUPPER ${_module} _module_upper)
|
|
Rex Dieter |
e5f144c |
+ set(QT_QT${_module_upper}_LIBRARIES ${Qt5${_module}_LIBRARIES})
|
|
Rex Dieter |
e5f144c |
+ set(QT_QT${_module_upper}_LIBRARY ${QT_QT${_module_upper}_LIBRARIES})
|
|
Rex Dieter |
e5f144c |
+ list(APPEND QT_INCLUDES ${Qt5${_module}_INCLUDE_DIRS})
|
|
Rex Dieter |
e5f144c |
+ set(QT_QT${_module_upper}_FOUND ${Qt5${_module}_FOUND})
|
|
Rex Dieter |
e5f144c |
+endforeach()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION)
|
|
Rex Dieter |
e5f144c |
+get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION)
|
|
Rex Dieter |
e5f144c |
+if (TARGET Qt5::uic)
|
|
Rex Dieter |
e5f144c |
+ get_target_property(QT_UIC_EXECUTABLE Qt5::uic LOCATION)
|
|
Rex Dieter |
e5f144c |
+endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+if (TARGET Qt5::qdbuscpp2xml)
|
|
Rex Dieter |
e5f144c |
+ get_target_property(QT_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml LOCATION)
|
|
Rex Dieter |
e5f144c |
+endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+if (TARGET Qt5::qdbusxml2cpp)
|
|
Rex Dieter |
e5f144c |
+ get_target_property(QT_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION)
|
|
Rex Dieter |
e5f144c |
+endif()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_wrap_ui)
|
|
Rex Dieter |
e5f144c |
+ qt5_wrap_ui(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_wrap_cpp)
|
|
Rex Dieter |
e5f144c |
+ qt5_wrap_cpp(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_generate_moc)
|
|
Rex Dieter |
e5f144c |
+ qt5_generate_moc(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_add_dbus_adaptor)
|
|
Rex Dieter |
e5f144c |
+ qt5_add_dbus_adaptor(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_add_dbus_interfaces)
|
|
Rex Dieter |
e5f144c |
+ qt5_add_dbus_interfaces(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_add_dbus_interface)
|
|
Rex Dieter |
e5f144c |
+ qt5_add_dbus_interface(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_generate_dbus_interface)
|
|
Rex Dieter |
e5f144c |
+ qt5_generate_dbus_interface(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
+
|
|
Rex Dieter |
e5f144c |
+macro(qt4_add_resources)
|
|
Rex Dieter |
e5f144c |
+ qt5_add_resources(${ARGN})
|
|
Rex Dieter |
e5f144c |
+endmacro()
|
|
Rex Dieter |
e5f144c |
diff --git a/lib/prison/CMakeLists.txt b/lib/prison/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
index 04d9a89..6916329 100644
|
|
Rex Dieter |
e5f144c |
--- a/lib/prison/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
+++ b/lib/prison/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
@@ -12,7 +12,7 @@ SET( prison_SRC
|
|
Rex Dieter |
e5f144c |
add_library(prison SHARED ${prison_SRC})
|
|
Rex Dieter |
e5f144c |
target_link_libraries(prison ${DMTX_LIBRARIES} ${QRENCODE_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
-set_target_properties(prison PROPERTIES VERSION "0.1.0" SOVERSION "0" LINK_INTERFACE_LIBRARIES "" DEFINE_SYMBOL BUILDING_PRISON)
|
|
Rex Dieter |
e5f144c |
+set_target_properties(prison PROPERTIES VERSION "0.2.0" SOVERSION "0" LINK_INTERFACE_LIBRARIES "" DEFINE_SYMBOL BUILDING_PRISON)
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
diff --git a/lib/prison/barcodewidget.cpp b/lib/prison/barcodewidget.cpp
|
|
Rex Dieter |
e5f144c |
index fc673c6..54edf13 100644
|
|
Rex Dieter |
e5f144c |
--- a/lib/prison/barcodewidget.cpp
|
|
Rex Dieter |
e5f144c |
+++ b/lib/prison/barcodewidget.cpp
|
|
Rex Dieter |
e5f144c |
@@ -28,6 +28,8 @@
|
|
Rex Dieter |
e5f144c |
#include "abstractbarcode.h"
|
|
Rex Dieter |
e5f144c |
#include <QResizeEvent>
|
|
Rex Dieter |
e5f144c |
#include <QPainter>
|
|
Rex Dieter |
e5f144c |
+#include <QMimeData>
|
|
Rex Dieter |
e5f144c |
+#include <QDrag>
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
using namespace prison;
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
diff --git a/testapp/CMakeLists.txt b/testapp/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
index c76f7ab..95d3403 100644
|
|
Rex Dieter |
e5f144c |
--- a/testapp/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
+++ b/testapp/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
@@ -1,7 +1,4 @@
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
-include_directories(${CMAKE_SOURCE_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR})
|
|
Rex Dieter |
e5f144c |
-
|
|
Rex Dieter |
e5f144c |
set(prison_SRCS prison.cpp main.cpp)
|
|
Rex Dieter |
e5f144c |
-qt4_automoc(${prison_SRCS})
|
|
Rex Dieter |
e5f144c |
add_executable(test-prison ${prison_SRCS})
|
|
Rex Dieter |
e5f144c |
-target_link_libraries(test-prison ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} prison)
|
|
Rex Dieter |
e5f144c |
+target_link_libraries(test-prison ${QT_QTGUI_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} prison)
|
|
Rex Dieter |
e5f144c |
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
index c2ad7c3..ea5132e 100644
|
|
Rex Dieter |
e5f144c |
--- a/tools/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
+++ b/tools/CMakeLists.txt
|
|
Rex Dieter |
e5f144c |
@@ -1,5 +1,5 @@
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
-find_package(Qt4 COMPONENTS QtGui QtCore REQUIRED)
|
|
Rex Dieter |
e5f144c |
+#find_package(Qt4 COMPONENTS QtGui QtCore REQUIRED)
|
|
Rex Dieter |
e5f144c |
|
|
Rex Dieter |
e5f144c |
add_executable(prison-datamatrix prison-datamatrix.cpp)
|
|
Rex Dieter |
e5f144c |
-target_link_libraries(prison-datamatrix prison ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
|
Rex Dieter |
e5f144c |
+target_link_libraries(prison-datamatrix prison ${QT_QTGUI_LIBRARIES} ${QT_QTCORE_LIBRARY})
|
|
Rex Dieter |
e5f144c |
--
|
|
Rex Dieter |
e5f144c |
2.5.0
|
|
Rex Dieter |
e5f144c |
|