THRIFT-2903 Qt4 library built with CMake does not work
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt
index cb68505..9a7d245 100644
--- a/lib/cpp/test/CMakeLists.txt
+++ b/lib/cpp/test/CMakeLists.txt
@@ -47,7 +47,7 @@
 add_library(testgencpp STATIC ${testgencpp_SOURCES})
 target_link_libraries(testgencpp thrift)
 
-set(processortest_SOURCES
+set(testgencpp_cob_SOURCES
     gen-cpp/ChildService.cpp
     gen-cpp/ChildService.h
     gen-cpp/ParentService.cpp
@@ -55,6 +55,8 @@
     gen-cpp/proc_types.cpp
     gen-cpp/proc_types.h
 )
+add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES})
+target_link_libraries(testgencpp_cob thrift)
 
 
 add_executable(Benchmark Benchmark.cpp)
@@ -182,11 +184,13 @@
 
 set(link_test_SOURCES
     link/LinkTest.cpp
+    gen-cpp/ParentService.h
     link/TemplatedService1.cpp
     link/TemplatedService2.cpp
-    gen-cpp/ParentService.h
 )
+
 add_executable(link_test ${link_test_SOURCES})
+target_link_libraries(concurrency_test testgencpp_cob thrift)
 add_test(NAME link_test COMMAND link_test)
 
 if(WITH_LIBEVENT)
@@ -200,6 +204,7 @@
 )
 add_executable(processor_test ${processor_test_SOURCES})
 target_link_libraries(processor_test
+    testgencpp_cob
     thrift
     thriftnb
     ${Boost_LIBRARIES}
@@ -217,6 +222,18 @@
 add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
 endif()
 
+if(WITH_QT4)
+cmake_minimum_required(VERSION 2.8.12)
+set(CMAKE_AUTOMOC ON)
+find_package(Qt4 REQUIRED COMPONENTS QtTest)
+set(TQTcpServerTest_SOURCES
+    qt/TQTcpServerTest.cpp
+)
+add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES})
+target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest)
+add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
+endif()
+
 #
 # Common thrift code generation rules
 #
diff --git a/lib/cpp/test/qt/TQTcpServerTest.cpp b/lib/cpp/test/qt/TQTcpServerTest.cpp
new file mode 100644
index 0000000..79c0dfc
--- /dev/null
+++ b/lib/cpp/test/qt/TQTcpServerTest.cpp
@@ -0,0 +1,89 @@
+#define BOOST_TEST_MODULE TQTcpServerTest
+#include <QTest>
+#include <boost/smart_ptr.hpp>
+#include <iostream>
+
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QHostAddress>
+
+#include "thrift/protocol/TBinaryProtocol.h"
+#include "thrift/async/TAsyncProcessor.h"
+#include "thrift/qt/TQTcpServer.h"
+#include "thrift/qt/TQIODeviceTransport.h"
+
+#include "gen-cpp/ParentService.h"
+
+using namespace apache::thrift;
+
+struct AsyncHandler : public test::ParentServiceCobSvIf {
+  std::vector<std::string> strings;
+  virtual void addString(tcxx::function<void()> cob, const std::string& s) {
+    strings.push_back(s);
+    cob();
+  }
+  virtual void getStrings(tcxx::function<void(std::vector<std::string> const& _return)> cob) {
+    cob(strings);
+  }
+
+  // Overrides not used in this test
+  virtual void incrementGeneration(tcxx::function<void(int32_t const& _return)> cob) {}
+  virtual void getGeneration(tcxx::function<void(int32_t const& _return)> cob) {}
+  virtual void getDataWait(tcxx::function<void(std::string const& _return)> cob,
+                           const int32_t length) {}
+  virtual void onewayWait(tcxx::function<void()> cob) {}
+  virtual void exceptionWait(
+      tcxx::function<void()> cob,
+      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */,
+      const std::string& message) {}
+  virtual void unexpectedExceptionWait(tcxx::function<void()> cob, const std::string& message) {}
+};
+
+class TQTcpServerTest : public QObject {
+  void init() {
+    // setup server
+    serverSocket.reset(new QTcpServer);
+    server.reset(new async::TQTcpServer(serverSocket,
+                                        boost::make_shared<test::ParentServiceAsyncProcessor>(
+                                            boost::make_shared<AsyncHandler>()),
+                                        boost::make_shared<protocol::TBinaryProtocolFactory>()));
+    QVERIFY(serverSocket->listen(QHostAddress::LocalHost));
+    int port = serverSocket->serverPort();
+    QVERIFY(port > 0);
+
+    // setup client
+    socket.reset(new QTcpSocket);
+    client.reset(new test::ParentServiceClient(boost::make_shared<protocol::TBinaryProtocol>(
+        boost::make_shared<transport::TQIODeviceTransport>(socket))));
+    socket->connectToHost(QHostAddress::LocalHost, port);
+    QVERIFY(socket->waitForConnected());
+  }
+
+  void cleanup() {
+    socket->close();
+    serverSocket->close();
+  }
+
+  void test_communicate() {
+    client->addString("foo");
+    client->addString("bar");
+
+    std::vector<std::string> reply;
+    client->getStrings(reply);
+    QCOMPARE(reply[0], "foo");
+    QCOMPARE(reply[1], "foo");
+  }
+
+  boost::shared_ptr<QTcpServer> serverSocket;
+  boost::shared_ptr<async::TQTcpServer> server;
+  boost::shared_ptr<QTcpSocket> socket;
+  boost::shared_ptr<test::ParentServiceClient> client;
+};
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+QTEST_GUILESS_MAIN(TQTcpServerTest);
+#else
+#undef QT_GUI_LIB
+QTEST_MAIN(TQTcpServerTest);
+#endif
+#include "TQTcpServerTest.moc"