blob: d07b4008c3f604ee28b4136c4065e0fac287505f [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
Jim King9de9b1f2015-04-30 16:03:34 -040020include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
Pascal Bachd5f87e12014-12-12 15:59:17 +010021include_directories(src)
22
23# SYSLIBS contains libraries that need to be linked to all lib targets
24set(SYSLIBS "")
25
26# Create the thrift C++ library
27set( thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010028 src/thrift/TApplicationException.cpp
Konrad Grochowski24ea0bf2015-05-07 14:59:29 +020029 src/thrift/TOutput.cpp
Jim King79c99112015-04-30 07:10:08 -040030 src/thrift/async/TAsyncChannel.cpp
ben-craig02bade12015-07-17 08:40:48 -050031 src/thrift/async/TConcurrentClientSyncInfo.h
32 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010033 src/thrift/concurrency/ThreadManager.cpp
34 src/thrift/concurrency/TimerManager.cpp
35 src/thrift/concurrency/Util.cpp
Jim King79c99112015-04-30 07:10:08 -040036 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050037 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010038 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010039 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010040 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050041 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010042 src/thrift/transport/TTransportException.cpp
43 src/thrift/transport/TFDTransport.cpp
44 src/thrift/transport/TSimpleFileTransport.cpp
45 src/thrift/transport/THttpTransport.cpp
46 src/thrift/transport/THttpClient.cpp
47 src/thrift/transport/THttpServer.cpp
48 src/thrift/transport/TSocket.cpp
49 src/thrift/transport/TSocketPool.cpp
50 src/thrift/transport/TServerSocket.cpp
51 src/thrift/transport/TTransportUtils.cpp
52 src/thrift/transport/TBufferTransports.cpp
Jim King5ec805b2015-04-26 07:52:40 -040053 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040054 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010055 src/thrift/server/TSimpleServer.cpp
56 src/thrift/server/TThreadPoolServer.cpp
57 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010058)
59
60# This files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040061# TODO: These files won't work with UNICODE support on windows. If fixed this can be re-added.
Pascal Bachd5f87e12014-12-12 15:59:17 +010062if (NOT WINCE)
63 list(APPEND thriftcpp_SOURCES
64 src/thrift/transport/TPipe.cpp
65 src/thrift/transport/TPipeServer.cpp
66 src/thrift/transport/TFileTransport.cpp
67 )
68endif()
69
70
71if (WIN32)
72 list(APPEND thriftcpp_SOURCES
73 src/thrift/windows/TWinsockSingleton.cpp
74 src/thrift/windows/SocketPair.cpp
75 src/thrift/windows/GetTimeOfDay.cpp
76 src/thrift/windows/WinFcntl.cpp
77 )
78 if(NOT WINCE)
79 # This file uses pipes so it currently won't work on Windows CE
80 list(APPEND thriftcpp_SOURCES
81 src/thrift/windows/OverlappedSubmissionThread.cpp
82 )
83 endif()
Ben Craig7207c222015-07-06 08:40:35 -050084else()
85 # These files evaluate to nothing on Windows, so omit them from the
86 # Windows build
87 list(APPEND thriftcpp_SOURCES
88 src/thrift/VirtualProfiling.cpp
89 src/thrift/server/TServer.cpp
90 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010091endif()
92
93# If OpenSSL is not found just ignore the OpenSSL stuff
94find_package(OpenSSL)
95if(OPENSSL_FOUND AND WITH_OPENSSL)
96 list( APPEND thriftcpp_SOURCES
97 src/thrift/transport/TSSLSocket.cpp
98 src/thrift/transport/TSSLServerSocket.cpp
99 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900100 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100101 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
102endif()
103
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900104# WITH_*THREADS selects which threading library to use
Pascal Bachd5f87e12014-12-12 15:59:17 +0100105if(WITH_BOOSTTHREADS)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106 set( thriftcpp_threads_SOURCES
107 src/thrift/concurrency/BoostThreadFactory.cpp
108 src/thrift/concurrency/BoostMonitor.cpp
109 src/thrift/concurrency/BoostMutex.cpp
110 )
111 list(APPEND SYSLIBS "${Boost_LIBRARIES}")
112elseif(UNIX AND NOT WITH_STDTHREADS)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900113 if(ANDROID)
114 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
115 else()
116 list(APPEND SYSLIBS pthread)
117 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100118 set( thriftcpp_threads_SOURCES
119 src/thrift/concurrency/PosixThreadFactory.cpp
120 src/thrift/concurrency/Mutex.cpp
121 src/thrift/concurrency/Monitor.cpp
122 )
123else()
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900124 if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900125 if(ANDROID)
126 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
127 else()
128 list(APPEND SYSLIBS pthread)
129 endif()
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900130 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100131 set( thriftcpp_threads_SOURCES
132 src/thrift/concurrency/StdThreadFactory.cpp
133 src/thrift/concurrency/StdMutex.cpp
134 src/thrift/concurrency/StdMonitor.cpp
135 )
136endif()
137
138# Thrift non blocking server
139set( thriftcppnb_SOURCES
140 src/thrift/server/TNonblockingServer.cpp
141 src/thrift/async/TAsyncProtocolProcessor.cpp
142 src/thrift/async/TEvhttpServer.cpp
143 src/thrift/async/TEvhttpClientChannel.cpp
144)
145
146# Thrift zlib server
147set( thriftcppz_SOURCES
148 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800149 src/thrift/protocol/THeaderProtocol.cpp
150 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900151 src/thrift/protocol/THeaderProtocol.cpp
152 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100153)
154
155# Thrift Qt4 server
156set( thriftcppqt_SOURCES
157 src/thrift/qt/TQIODeviceTransport.cpp
158 src/thrift/qt/TQTcpServer.cpp
159)
160
161# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
162include(ThriftMacros)
163
164ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100165if(WIN32)
166 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
167else()
168 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
169endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100170
171if(WITH_LIBEVENT)
172 find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900173 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100174
175 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400176 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
177 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100178endif()
179
180if(WITH_ZLIB)
181 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900182 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100183
184 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400185 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
186 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100187endif()
188
Pascal Bachd5f87e12014-12-12 15:59:17 +0100189if(WITH_QT4)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900190 set(CMAKE_AUTOMOC ON)
191 find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100192 ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400193 TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
194 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftqt thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100195endif()
196
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900197if(WITH_QT5)
198 # Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC
199 add_subdirectory(src/thrift/qt)
200endif()
201
Pascal Bachd5f87e12014-12-12 15:59:17 +0100202if(MSVC)
203 add_definitions("-DUNICODE -D_UNICODE")
204endif()
205
Jim King79c99112015-04-30 07:10:08 -0400206add_definitions("-D__STDC_LIMIT_MACROS")
207
Pascal Bachd5f87e12014-12-12 15:59:17 +0100208# Install the headers
209install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
210 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
211# Copy config.h file
212install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
213 FILES_MATCHING PATTERN "*.h")
214
215if(BUILD_TESTING)
216 add_subdirectory(test)
217endif()