blob: b3a34d095c24da80fb479fdc95206f97b698158e [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
James E. King IIIc9ac8d22019-01-07 16:46:45 -050020# Remove the following once lib/cpp no longer depends on boost headers:
21include(BoostMacros)
22REQUIRE_BOOST_HEADERS()
23
Pascal Bachd5f87e12014-12-12 15:59:17 +010024include_directories(src)
25
cyy8fdb7582019-02-05 02:57:21 +080026if(NOT BUILD_SHARED_LIBS)
27 add_definitions("-DTHRIFT_STATIC_DEFINE")
28endif()
29
Pascal Bachd5f87e12014-12-12 15:59:17 +010030# SYSLIBS contains libraries that need to be linked to all lib targets
31set(SYSLIBS "")
32
33# Create the thrift C++ library
34set( thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010035 src/thrift/TApplicationException.cpp
Konrad Grochowski24ea0bf2015-05-07 14:59:29 +020036 src/thrift/TOutput.cpp
Jim King79c99112015-04-30 07:10:08 -040037 src/thrift/async/TAsyncChannel.cpp
Stefan Bolus9edecce2018-06-06 20:32:52 +020038 src/thrift/async/TAsyncProtocolProcessor.cpp
ben-craig02bade12015-07-17 08:40:48 -050039 src/thrift/async/TConcurrentClientSyncInfo.h
40 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010041 src/thrift/concurrency/ThreadManager.cpp
42 src/thrift/concurrency/TimerManager.cpp
Jim King79c99112015-04-30 07:10:08 -040043 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050044 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010045 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010046 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010047 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050048 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010049 src/thrift/transport/TTransportException.cpp
50 src/thrift/transport/TFDTransport.cpp
51 src/thrift/transport/TSimpleFileTransport.cpp
52 src/thrift/transport/THttpTransport.cpp
53 src/thrift/transport/THttpClient.cpp
54 src/thrift/transport/THttpServer.cpp
55 src/thrift/transport/TSocket.cpp
56 src/thrift/transport/TSocketPool.cpp
57 src/thrift/transport/TServerSocket.cpp
58 src/thrift/transport/TTransportUtils.cpp
59 src/thrift/transport/TBufferTransports.cpp
penenin1ab096c2020-05-18 12:27:31 -070060 src/thrift/transport/TWebSocketServer.h
61 src/thrift/transport/TWebSocketServer.cpp
David Suárez4750f362020-09-09 15:49:37 +020062 src/thrift/transport/SocketCommon.cpp
Jim King5ec805b2015-04-26 07:52:40 -040063 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040064 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010065 src/thrift/server/TSimpleServer.cpp
66 src/thrift/server/TThreadPoolServer.cpp
67 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010068)
69
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020070# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040071# 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 +010072if (NOT WINCE)
73 list(APPEND thriftcpp_SOURCES
74 src/thrift/transport/TPipe.cpp
75 src/thrift/transport/TPipeServer.cpp
76 src/thrift/transport/TFileTransport.cpp
77 )
78endif()
79
80
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020081if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010082 list(APPEND thriftcpp_SOURCES
83 src/thrift/windows/TWinsockSingleton.cpp
84 src/thrift/windows/SocketPair.cpp
85 src/thrift/windows/GetTimeOfDay.cpp
86 src/thrift/windows/WinFcntl.cpp
87 )
88 if(NOT WINCE)
89 # This file uses pipes so it currently won't work on Windows CE
90 list(APPEND thriftcpp_SOURCES
91 src/thrift/windows/OverlappedSubmissionThread.cpp
92 )
93 endif()
Ben Craig7207c222015-07-06 08:40:35 -050094else()
95 # These files evaluate to nothing on Windows, so omit them from the
96 # Windows build
97 list(APPEND thriftcpp_SOURCES
98 src/thrift/VirtualProfiling.cpp
99 src/thrift/server/TServer.cpp
100 )
Pascal Bachd5f87e12014-12-12 15:59:17 +0100101endif()
102
James E. King III17355422019-01-11 23:06:08 -0500103# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
Pascal Bachd5f87e12014-12-12 15:59:17 +0100104if(OPENSSL_FOUND AND WITH_OPENSSL)
105 list( APPEND thriftcpp_SOURCES
106 src/thrift/transport/TSSLSocket.cpp
107 src/thrift/transport/TSSLServerSocket.cpp
108 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900109 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100110 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
111endif()
112
cyyca8af9b2019-01-11 22:13:12 +0800113if(UNIX)
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 +0100119endif()
cyyca8af9b2019-01-11 22:13:12 +0800120set( thriftcpp_threads_SOURCES
121 src/thrift/concurrency/ThreadFactory.cpp
122 src/thrift/concurrency/Thread.cpp
123 src/thrift/concurrency/Monitor.cpp
124 src/thrift/concurrency/Mutex.cpp
125)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100126
127# Thrift non blocking server
128set( thriftcppnb_SOURCES
129 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700130 src/thrift/transport/TNonblockingServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100131 src/thrift/async/TEvhttpServer.cpp
132 src/thrift/async/TEvhttpClientChannel.cpp
133)
134
cyy13e6f9e2019-12-12 21:13:31 +0800135# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
136if(OPENSSL_FOUND AND WITH_OPENSSL)
137 list( APPEND thriftcppnb_SOURCES
138 src/thrift/transport/TNonblockingSSLServerSocket.cpp
139 )
140endif()
141
James E. King III17355422019-01-11 23:06:08 -0500142# Thrift zlib transport
Pascal Bachd5f87e12014-12-12 15:59:17 +0100143set( thriftcppz_SOURCES
144 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800145 src/thrift/protocol/THeaderProtocol.cpp
146 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900147 src/thrift/protocol/THeaderProtocol.cpp
148 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100149)
150
Pascal Bachd5f87e12014-12-12 15:59:17 +0100151# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
152include(ThriftMacros)
153
154ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100155if(WIN32)
156 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
157else()
158 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
159endif()
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500160ADD_PKGCONFIG_THRIFT(thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100161
162if(WITH_LIBEVENT)
Tobias Mayerc8e46cf2020-02-16 10:36:11 +0100163 find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900164 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100165
166 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
James E. King III278528c2019-01-11 12:17:44 -0500167 LINK_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Jim King9de9b1f2015-04-30 16:03:34 -0400168 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500169 ADD_PKGCONFIG_THRIFT(thrift-nb)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100170endif()
171
172if(WITH_ZLIB)
173 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900174 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100175
176 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400177 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
178 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500179 ADD_PKGCONFIG_THRIFT(thrift-z)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100180endif()
181
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900182if(WITH_QT5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900183 add_subdirectory(src/thrift/qt)
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500184 ADD_PKGCONFIG_THRIFT(thrift-qt5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900185endif()
186
Pascal Bachd5f87e12014-12-12 15:59:17 +0100187if(MSVC)
188 add_definitions("-DUNICODE -D_UNICODE")
189endif()
190
Pascal Bachd5f87e12014-12-12 15:59:17 +0100191# Install the headers
192install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
193 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
194# Copy config.h file
195install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
196 FILES_MATCHING PATTERN "*.h")
197
198if(BUILD_TESTING)
199 add_subdirectory(test)
200endif()