blob: 1ed0bfadfebb5bd0b6bff1d96ff4215f0685180e [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
Stefan Bolus9edecce2018-06-06 20:32:52 +020031 src/thrift/async/TAsyncProtocolProcessor.cpp
ben-craig02bade12015-07-17 08:40:48 -050032 src/thrift/async/TConcurrentClientSyncInfo.h
33 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010034 src/thrift/concurrency/ThreadManager.cpp
35 src/thrift/concurrency/TimerManager.cpp
36 src/thrift/concurrency/Util.cpp
Jim King79c99112015-04-30 07:10:08 -040037 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050038 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010039 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010040 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010041 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050042 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010043 src/thrift/transport/TTransportException.cpp
44 src/thrift/transport/TFDTransport.cpp
45 src/thrift/transport/TSimpleFileTransport.cpp
46 src/thrift/transport/THttpTransport.cpp
47 src/thrift/transport/THttpClient.cpp
48 src/thrift/transport/THttpServer.cpp
49 src/thrift/transport/TSocket.cpp
50 src/thrift/transport/TSocketPool.cpp
51 src/thrift/transport/TServerSocket.cpp
52 src/thrift/transport/TTransportUtils.cpp
53 src/thrift/transport/TBufferTransports.cpp
Jim King5ec805b2015-04-26 07:52:40 -040054 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040055 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010056 src/thrift/server/TSimpleServer.cpp
57 src/thrift/server/TThreadPoolServer.cpp
58 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010059)
60
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020061# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040062# 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 +010063if (NOT WINCE)
64 list(APPEND thriftcpp_SOURCES
65 src/thrift/transport/TPipe.cpp
66 src/thrift/transport/TPipeServer.cpp
67 src/thrift/transport/TFileTransport.cpp
68 )
69endif()
70
71
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020072if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010073 list(APPEND thriftcpp_SOURCES
74 src/thrift/windows/TWinsockSingleton.cpp
75 src/thrift/windows/SocketPair.cpp
76 src/thrift/windows/GetTimeOfDay.cpp
77 src/thrift/windows/WinFcntl.cpp
78 )
79 if(NOT WINCE)
80 # This file uses pipes so it currently won't work on Windows CE
81 list(APPEND thriftcpp_SOURCES
82 src/thrift/windows/OverlappedSubmissionThread.cpp
83 )
84 endif()
Ben Craig7207c222015-07-06 08:40:35 -050085else()
86 # These files evaluate to nothing on Windows, so omit them from the
87 # Windows build
88 list(APPEND thriftcpp_SOURCES
89 src/thrift/VirtualProfiling.cpp
90 src/thrift/server/TServer.cpp
91 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010092endif()
93
94# If OpenSSL is not found just ignore the OpenSSL stuff
95find_package(OpenSSL)
96if(OPENSSL_FOUND AND WITH_OPENSSL)
97 list( APPEND thriftcpp_SOURCES
98 src/thrift/transport/TSSLSocket.cpp
99 src/thrift/transport/TSSLServerSocket.cpp
100 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900101 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100102 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
103endif()
104
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900105# WITH_*THREADS selects which threading library to use
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106if(WITH_BOOSTTHREADS)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100107 set( thriftcpp_threads_SOURCES
108 src/thrift/concurrency/BoostThreadFactory.cpp
109 src/thrift/concurrency/BoostMonitor.cpp
110 src/thrift/concurrency/BoostMutex.cpp
111 )
112 list(APPEND SYSLIBS "${Boost_LIBRARIES}")
113elseif(UNIX AND NOT WITH_STDTHREADS)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900114 if(ANDROID)
115 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
116 else()
117 list(APPEND SYSLIBS pthread)
118 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100119 set( thriftcpp_threads_SOURCES
120 src/thrift/concurrency/PosixThreadFactory.cpp
121 src/thrift/concurrency/Mutex.cpp
122 src/thrift/concurrency/Monitor.cpp
123 )
124else()
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900125 if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900126 if(ANDROID)
127 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
128 else()
129 list(APPEND SYSLIBS pthread)
130 endif()
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900131 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100132 set( thriftcpp_threads_SOURCES
133 src/thrift/concurrency/StdThreadFactory.cpp
134 src/thrift/concurrency/StdMutex.cpp
135 src/thrift/concurrency/StdMonitor.cpp
136 )
137endif()
138
139# Thrift non blocking server
140set( thriftcppnb_SOURCES
141 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700142 src/thrift/transport/TNonblockingServerSocket.cpp
143 src/thrift/transport/TNonblockingSSLServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100144 src/thrift/async/TEvhttpServer.cpp
145 src/thrift/async/TEvhttpClientChannel.cpp
146)
147
148# Thrift zlib server
149set( thriftcppz_SOURCES
150 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800151 src/thrift/protocol/THeaderProtocol.cpp
152 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900153 src/thrift/protocol/THeaderProtocol.cpp
154 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100155)
156
157# Thrift Qt4 server
158set( thriftcppqt_SOURCES
159 src/thrift/qt/TQIODeviceTransport.cpp
160 src/thrift/qt/TQTcpServer.cpp
161)
162
163# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
164include(ThriftMacros)
165
166ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100167if(WIN32)
168 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
169else()
170 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
171endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100172
173if(WITH_LIBEVENT)
174 find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900175 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100176
177 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400178 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
179 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100180endif()
181
182if(WITH_ZLIB)
183 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900184 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100185
186 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400187 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
188 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100189endif()
190
Pascal Bachd5f87e12014-12-12 15:59:17 +0100191if(WITH_QT4)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900192 set(CMAKE_AUTOMOC ON)
193 find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100194 ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400195 TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
196 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftqt thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100197endif()
198
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900199if(WITH_QT5)
200 # Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC
201 add_subdirectory(src/thrift/qt)
202endif()
203
Pascal Bachd5f87e12014-12-12 15:59:17 +0100204if(MSVC)
205 add_definitions("-DUNICODE -D_UNICODE")
206endif()
207
Jim King79c99112015-04-30 07:10:08 -0400208add_definitions("-D__STDC_LIMIT_MACROS")
209
Pascal Bachd5f87e12014-12-12 15:59:17 +0100210# Install the headers
211install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
212 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
213# Copy config.h file
214install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
215 FILES_MATCHING PATTERN "*.h")
216
217if(BUILD_TESTING)
218 add_subdirectory(test)
219endif()