blob: 5980734f3803a67f9f95881969f5fef22a739b21 [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# Create the thrift C++ library
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020031set(thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010032 src/thrift/TApplicationException.cpp
Konrad Grochowski24ea0bf2015-05-07 14:59:29 +020033 src/thrift/TOutput.cpp
CJCombrink4b909092024-04-27 19:51:39 +020034 src/thrift/TUuid.cpp
Jim King79c99112015-04-30 07:10:08 -040035 src/thrift/async/TAsyncChannel.cpp
Stefan Bolus9edecce2018-06-06 20:32:52 +020036 src/thrift/async/TAsyncProtocolProcessor.cpp
ben-craig02bade12015-07-17 08:40:48 -050037 src/thrift/async/TConcurrentClientSyncInfo.h
38 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010039 src/thrift/concurrency/ThreadManager.cpp
40 src/thrift/concurrency/TimerManager.cpp
Jim King79c99112015-04-30 07:10:08 -040041 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050042 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010043 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010044 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010045 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050046 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010047 src/thrift/transport/TTransportException.cpp
48 src/thrift/transport/TFDTransport.cpp
49 src/thrift/transport/TSimpleFileTransport.cpp
50 src/thrift/transport/THttpTransport.cpp
51 src/thrift/transport/THttpClient.cpp
52 src/thrift/transport/THttpServer.cpp
53 src/thrift/transport/TSocket.cpp
54 src/thrift/transport/TSocketPool.cpp
55 src/thrift/transport/TServerSocket.cpp
56 src/thrift/transport/TTransportUtils.cpp
57 src/thrift/transport/TBufferTransports.cpp
David Suárez4750f362020-09-09 15:49:37 +020058 src/thrift/transport/SocketCommon.cpp
Jim King5ec805b2015-04-26 07:52:40 -040059 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040060 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010061 src/thrift/server/TSimpleServer.cpp
62 src/thrift/server/TThreadPoolServer.cpp
63 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010064)
65
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020066# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040067# 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 +010068if (NOT WINCE)
69 list(APPEND thriftcpp_SOURCES
70 src/thrift/transport/TPipe.cpp
71 src/thrift/transport/TPipeServer.cpp
72 src/thrift/transport/TFileTransport.cpp
73 )
74endif()
75
76
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020077if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010078 list(APPEND thriftcpp_SOURCES
79 src/thrift/windows/TWinsockSingleton.cpp
80 src/thrift/windows/SocketPair.cpp
81 src/thrift/windows/GetTimeOfDay.cpp
82 src/thrift/windows/WinFcntl.cpp
83 )
84 if(NOT WINCE)
85 # This file uses pipes so it currently won't work on Windows CE
86 list(APPEND thriftcpp_SOURCES
87 src/thrift/windows/OverlappedSubmissionThread.cpp
88 )
89 endif()
Ben Craig7207c222015-07-06 08:40:35 -050090else()
91 # These files evaluate to nothing on Windows, so omit them from the
92 # Windows build
93 list(APPEND thriftcpp_SOURCES
94 src/thrift/VirtualProfiling.cpp
95 src/thrift/server/TServer.cpp
96 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010097endif()
98
James E. King III17355422019-01-11 23:06:08 -050099# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
Pascal Bachd5f87e12014-12-12 15:59:17 +0100100if(OPENSSL_FOUND AND WITH_OPENSSL)
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200101 list(APPEND thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +0100102 src/thrift/transport/TSSLSocket.cpp
103 src/thrift/transport/TSSLServerSocket.cpp
Kevin Wojniak2853af22021-10-20 20:56:29 -0700104 src/thrift/transport/TWebSocketServer.h
105 src/thrift/transport/TWebSocketServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106 )
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200107 if(TARGET OpenSSL::SSL OR TARGET OpenSSL::Crypto)
108 if(TARGET OpenSSL::SSL)
109 list(APPEND SYSLIBS OpenSSL::SSL)
110 endif()
111 if(TARGET OpenSSL::Crypto)
112 list(APPEND SYSLIBS OpenSSL::Crypto)
113 endif()
114 else()
115 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
116 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
117 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100118endif()
119
cyyca8af9b2019-01-11 22:13:12 +0800120if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900121 if(ANDROID)
122 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
123 else()
124 list(APPEND SYSLIBS pthread)
125 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100126endif()
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200127
128set(thriftcpp_threads_SOURCES
cyyca8af9b2019-01-11 22:13:12 +0800129 src/thrift/concurrency/ThreadFactory.cpp
130 src/thrift/concurrency/Thread.cpp
131 src/thrift/concurrency/Monitor.cpp
132 src/thrift/concurrency/Mutex.cpp
133)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100134
135# Thrift non blocking server
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200136set(thriftcppnb_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +0100137 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700138 src/thrift/transport/TNonblockingServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100139 src/thrift/async/TEvhttpServer.cpp
140 src/thrift/async/TEvhttpClientChannel.cpp
141)
142
cyy13e6f9e2019-12-12 21:13:31 +0800143# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
144if(OPENSSL_FOUND AND WITH_OPENSSL)
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200145 list(APPEND thriftcppnb_SOURCES
cyy13e6f9e2019-12-12 21:13:31 +0800146 src/thrift/transport/TNonblockingSSLServerSocket.cpp
147 )
148endif()
149
James E. King III17355422019-01-11 23:06:08 -0500150# Thrift zlib transport
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200151set(thriftcppz_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +0100152 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800153 src/thrift/protocol/THeaderProtocol.cpp
154 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900155 src/thrift/protocol/THeaderProtocol.cpp
156 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100157)
158
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200159# Contains the thrift specific ADD_LIBRARY_THRIFT macro
Pascal Bachd5f87e12014-12-12 15:59:17 +0100160include(ThriftMacros)
161
162ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200163target_link_libraries(thrift PUBLIC ${SYSLIBS})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100164if(WIN32)
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200165 target_link_libraries(thrift PUBLIC ws2_32)
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100166endif()
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500167ADD_PKGCONFIG_THRIFT(thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100168
169if(WITH_LIBEVENT)
Tobias Mayerc8e46cf2020-02-16 10:36:11 +0100170 find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900171 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100172
173 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200174 target_link_libraries(thriftnb PUBLIC thrift)
Mario Emmenlauer7553fc52020-11-19 15:19:23 +0100175 if(TARGET libevent::core AND TARGET libevent::extra)
176 # libevent was found via its cmake config, use modern style targets
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200177 target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra)
Mario Emmenlauer7553fc52020-11-19 15:19:23 +0100178 else()
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200179 target_link_libraries(thriftnb PUBLIC ${LIBEVENT_LIBRARIES})
Mario Emmenlauer7553fc52020-11-19 15:19:23 +0100180 endif()
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500181 ADD_PKGCONFIG_THRIFT(thrift-nb)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100182endif()
183
184if(WITH_ZLIB)
185 find_package(ZLIB REQUIRED)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100186
187 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200188 target_link_libraries(thriftz PUBLIC thrift)
Tobias Weihsfe739722022-08-19 10:49:51 +0200189
190 if(TARGET ZLIB::ZLIB)
191 target_link_libraries(thriftz PUBLIC ZLIB::ZLIB)
192 else()
193 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
194 target_link_libraries(thriftz PUBLIC ${ZLIB_LIBRARIES})
195 endif()
196
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500197 ADD_PKGCONFIG_THRIFT(thrift-z)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100198endif()
199
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900200if(WITH_QT5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900201 add_subdirectory(src/thrift/qt)
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500202 ADD_PKGCONFIG_THRIFT(thrift-qt5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900203endif()
204
Pascal Bachd5f87e12014-12-12 15:59:17 +0100205if(MSVC)
206 add_definitions("-DUNICODE -D_UNICODE")
207endif()
208
Pascal Bachd5f87e12014-12-12 15:59:17 +0100209# Install the headers
210install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
211 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
212# Copy config.h file
213install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
214 FILES_MATCHING PATTERN "*.h")
215
216if(BUILD_TESTING)
217 add_subdirectory(test)
218endif()