THRIFT-2903 Qt4 library built with CMake does not work
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
index 4f2e451..25b551e 100755
--- a/lib/cpp/CMakeLists.txt
+++ b/lib/cpp/CMakeLists.txt
@@ -172,13 +172,12 @@
     TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
 endif()
 
-
 if(WITH_QT4)
-    find_package(Qt4 REQUIRED)
-    include_directories(${QT_INCLUDES})
-
+    cmake_minimum_required(VERSION 2.8.12)
+    set(CMAKE_AUTOMOC ON)
+    find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
     ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
-    TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${QT_LIBRARIES})
+    TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
 endif()
 
 if(MSVC)