mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 18:35:19 +00:00
THRIFT-2098 Add support for Qt5+
This commit is contained in:
parent
6304a53414
commit
6622877a09
1
.gitignore
vendored
1
.gitignore
vendored
@ -81,6 +81,7 @@ test-driver
|
||||
/lib/cpp/Release/
|
||||
/lib/cpp/Release-mt/
|
||||
/lib/cpp/src/thrift/qt/moc_TQTcpServer.cpp
|
||||
/lib/cpp/src/thrift/qt/moc__TQTcpServer.cpp
|
||||
/lib/cpp/src/thrift/config.h
|
||||
/lib/cpp/src/thrift/stamp-h2
|
||||
/lib/cpp/test/Benchmark
|
||||
|
@ -50,6 +50,13 @@ CMAKE_DEPENDENT_OPTION(WITH_LIBEVENT "Build with libevent support" ON
|
||||
find_package(Qt4 QUIET COMPONENTS QtCore QtNetwork)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_QT4 "Build with Qt4 support" ON
|
||||
"QT4_FOUND" OFF)
|
||||
find_package(Qt5 QUIET COMPONENTS Core Network)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_QT5 "Build with Qt5 support" ON
|
||||
"Qt5_FOUND" OFF)
|
||||
if(${WITH_QT4} AND ${WITH_QT5} AND ${CMAKE_MAJOR_VERSION} LESS 3)
|
||||
# cmake < 3.0.0 causes conflict when building both Qt4 and Qt5
|
||||
set(WITH_QT4 OFF)
|
||||
endif()
|
||||
find_package(OpenSSL QUIET)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_OPENSSL "Build with OpenSSL support" ON
|
||||
"OpenSSL_FOUND" OFF)
|
||||
@ -95,6 +102,7 @@ message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
|
||||
message(STATUS " Build with ZLIB support: ${WITH_ZLIB}")
|
||||
message(STATUS " Build with libevent support: ${WITH_LIBEVENT}")
|
||||
message(STATUS " Build with Qt4 support: ${WITH_QT4}")
|
||||
message(STATUS " Build with Qt5 support: ${WITH_QT5}")
|
||||
message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
|
||||
message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
|
||||
message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
|
||||
|
19
configure.ac
19
configure.ac
@ -156,11 +156,26 @@ if test "$with_cpp" = "yes"; then
|
||||
AC_PATH_PROGS([QT_MOC], [moc-qt4 moc])
|
||||
have_qt=$success
|
||||
fi
|
||||
|
||||
AX_THRIFT_LIB(qt5, [Qt5], yes)
|
||||
have_qt5=no
|
||||
qt_reduce_reloc=""
|
||||
if test "$with_qt5" = "yes"; then
|
||||
PKG_CHECK_MODULES([QT5], [Qt5Core >= 5.0, Qt5Network >= 5.0],
|
||||
[have_qt5=yes;qt_reduce_reloc=`$PKG_CONFIG --variable=qt_config Qt5Core | grep "reduce_relocations"`],
|
||||
[have_qt5=no])
|
||||
fi
|
||||
if test "$have_qt5" = "yes"; then
|
||||
AC_PATH_PROGS([QT5_MOC], [moc-qt5 moc])
|
||||
have_qt5=$success
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_CPP], [test "$have_cpp" = "yes"])
|
||||
AM_CONDITIONAL([AMX_HAVE_LIBEVENT], [test "$have_libevent" = "yes"])
|
||||
AM_CONDITIONAL([AMX_HAVE_ZLIB], [test "$have_zlib" = "yes"])
|
||||
AM_CONDITIONAL([AMX_HAVE_QT], [test "$have_qt" = "yes"])
|
||||
AM_CONDITIONAL([AMX_HAVE_QT5], [test "$have_qt5" = "yes"])
|
||||
AM_CONDITIONAL([QT5_REDUCE_RELOCATIONS], [test "x$qt_reduce_reloc" != "x"])
|
||||
|
||||
AX_THRIFT_LIB(c_glib, [C (GLib)], yes)
|
||||
if test "$with_c_glib" = "yes"; then
|
||||
@ -649,6 +664,7 @@ AC_CONFIG_FILES([
|
||||
lib/cpp/thrift-nb.pc
|
||||
lib/cpp/thrift-z.pc
|
||||
lib/cpp/thrift-qt.pc
|
||||
lib/cpp/thrift-qt5.pc
|
||||
lib/cpp/thrift.pc
|
||||
lib/c_glib/Makefile
|
||||
lib/c_glib/thrift_c_glib.pc
|
||||
@ -726,7 +742,8 @@ if test "$have_cpp" = "yes" ; then
|
||||
echo "C++ Library:"
|
||||
echo " Build TZlibTransport ...... : $have_zlib"
|
||||
echo " Build TNonblockingServer .. : $have_libevent"
|
||||
echo " Build TQTcpServer (Qt) .... : $have_qt"
|
||||
echo " Build TQTcpServer (Qt4) .... : $have_qt"
|
||||
echo " Build TQTcpServer (Qt5) .... : $have_qt5"
|
||||
fi
|
||||
if test "$have_java" = "yes" ; then
|
||||
echo
|
||||
|
@ -21,9 +21,9 @@
|
||||
# Mainly aiming Travis CI's Ubuntu machines for now
|
||||
# see what we need: http://thrift.apache.org/docs/install/ubuntu
|
||||
|
||||
|
||||
# General dependencies
|
||||
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ trusty main restricted" -y
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qq libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev make cmake libqt4-dev git debhelper bc
|
||||
|
||||
sudo apt-get install -qq libpango-1.0-0 libqt4-dev qtbase5-dev qtbase5-dev-tools qt5-default libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev make cmake git debhelper bc
|
||||
dpkg -S /usr/include/boost/version.hpp
|
||||
|
@ -180,6 +180,11 @@ if(WITH_QT4)
|
||||
TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
|
||||
endif()
|
||||
|
||||
if(WITH_QT5)
|
||||
# Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC
|
||||
add_subdirectory(src/thrift/qt)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_definitions("-DUNICODE -D_UNICODE")
|
||||
endif()
|
||||
|
@ -22,6 +22,9 @@ AUTOMAKE_OPTIONS = subdir-objects
|
||||
moc_%.cpp: %.h
|
||||
$(QT_MOC) $(QT_CFLAGS) $< -o $@
|
||||
|
||||
moc__%.cpp: %.h
|
||||
$(QT5_MOC) $(QT5_CFLAGS) $< -o $@
|
||||
|
||||
SUBDIRS = .
|
||||
|
||||
if WITH_TESTS
|
||||
@ -48,6 +51,10 @@ if AMX_HAVE_QT
|
||||
lib_LTLIBRARIES += libthriftqt.la
|
||||
pkgconfig_DATA += thrift-qt.pc
|
||||
endif
|
||||
if AMX_HAVE_QT5
|
||||
lib_LTLIBRARIES += libthriftqt5.la
|
||||
pkgconfig_DATA += thrift-qt5.pc
|
||||
endif
|
||||
|
||||
AM_CXXFLAGS = -Wall -Wextra -pedantic
|
||||
AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(OPENSSL_INCLUDES) -I$(srcdir)/src
|
||||
@ -112,16 +119,28 @@ libthriftqt_la_SOURCES = $(libthriftqt_la_MOC) \
|
||||
src/thrift/qt/TQTcpServer.cpp
|
||||
CLEANFILES = $(libthriftqt_la_MOC)
|
||||
|
||||
libthriftqt5_la_MOC = src/thrift/qt/moc__TQTcpServer.cpp
|
||||
libthriftqt5_la_SOURCES = $(libthriftqt5_la_MOC) \
|
||||
src/thrift/qt/TQIODeviceTransport.cpp \
|
||||
src/thrift/qt/TQTcpServer.cpp
|
||||
CLEANFILES = $(libthriftqt5_la_MOC)
|
||||
|
||||
# Flags for the various libraries
|
||||
libthriftnb_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBEVENT_CPPFLAGS)
|
||||
libthriftz_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS)
|
||||
libthriftqt_la_CPPFLAGS = $(AM_CPPFLAGS) $(QT_CFLAGS)
|
||||
libthriftqt5_la_CPPFLAGS = $(AM_CPPFLAGS) $(QT5_CFLAGS)
|
||||
if QT5_REDUCE_RELOCATIONS
|
||||
libthriftqt5_la_CPPFLAGS += -fPIC
|
||||
endif
|
||||
libthriftnb_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libthriftz_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libthriftqt_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libthriftqt5_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libthriftnb_la_LDFLAGS = -release $(VERSION) $(BOOST_LDFLAGS)
|
||||
libthriftz_la_LDFLAGS = -release $(VERSION) $(BOOST_LDFLAGS)
|
||||
libthriftqt_la_LDFLAGS = -release $(VERSION) $(BOOST_LDFLAGS) $(QT_LIBS)
|
||||
libthriftqt5_la_LDFLAGS = -release $(VERSION) $(BOOST_LDFLAGS) $(QT5_LIBS)
|
||||
|
||||
include_thriftdir = $(includedir)/thrift
|
||||
include_thrift_HEADERS = \
|
||||
@ -242,6 +261,7 @@ EXTRA_DIST = \
|
||||
thrift.pc.in \
|
||||
thrift-z.pc.in \
|
||||
thrift-qt.pc.in \
|
||||
thrift-qt5.pc.in \
|
||||
$(WINDOWS_DIST)
|
||||
|
||||
style-local:
|
||||
|
30
lib/cpp/src/thrift/qt/CMakeLists.txt
Normal file
30
lib/cpp/src/thrift/qt/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
set( thriftcppqt5_SOURCES
|
||||
TQIODeviceTransport.cpp
|
||||
TQTcpServer.cpp
|
||||
)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Network)
|
||||
ADD_LIBRARY_THRIFT(thriftqt5 ${thriftcppqt5_SOURCES})
|
||||
TARGET_LINK_LIBRARIES_THRIFT(thriftqt5 Qt5::Core Qt5::Network)
|
@ -234,6 +234,10 @@ target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest
|
||||
add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
|
||||
endif()
|
||||
|
||||
if(WITH_QT5)
|
||||
add_subdirectory(qt)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Common thrift code generation rules
|
||||
#
|
||||
|
31
lib/cpp/test/qt/CMakeLists.txt
Normal file
31
lib/cpp/test/qt/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Test)
|
||||
set(TQTcpServerTest_Qt5_SOURCES
|
||||
TQTcpServerTest.cpp
|
||||
)
|
||||
add_executable(TQTcpServerTest_Qt5 ${TQTcpServerTest_Qt5_SOURCES})
|
||||
target_link_libraries(TQTcpServerTest_Qt5 testgencpp_cob thriftqt5 thrift Qt5::Test)
|
||||
add_test(NAME TQTcpServerTest_Qt5 COMMAND TQTcpServerTest_Qt5)
|
||||
|
30
lib/cpp/thrift-qt5.pc.in
Executable file
30
lib/cpp/thrift-qt5.pc.in
Executable file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: Thrift
|
||||
Description: Thrift Qt5 API
|
||||
Version: @VERSION@
|
||||
Requires: thrift = @VERSION@
|
||||
Libs: -L${libdir} -lthriftqt5
|
||||
Cflags: -I${includedir}
|
Loading…
Reference in New Issue
Block a user