Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 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 III | c9ac8d2 | 2019-01-07 16:46:45 -0500 | [diff] [blame] | 20 | # Remove the following once lib/cpp no longer depends on boost headers: |
| 21 | include(BoostMacros) |
| 22 | REQUIRE_BOOST_HEADERS() |
| 23 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 24 | include_directories(src) |
| 25 | |
cyy | 8fdb758 | 2019-02-05 02:57:21 +0800 | [diff] [blame] | 26 | if(NOT BUILD_SHARED_LIBS) |
| 27 | add_definitions("-DTHRIFT_STATIC_DEFINE") |
| 28 | endif() |
| 29 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 30 | # Create the thrift C++ library |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 31 | set(thriftcpp_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 32 | src/thrift/TApplicationException.cpp |
Konrad Grochowski | 24ea0bf | 2015-05-07 14:59:29 +0200 | [diff] [blame] | 33 | src/thrift/TOutput.cpp |
CJCombrink | 4b90909 | 2024-04-27 19:51:39 +0200 | [diff] [blame^] | 34 | src/thrift/TUuid.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 35 | src/thrift/async/TAsyncChannel.cpp |
Stefan Bolus | 9edecce | 2018-06-06 20:32:52 +0200 | [diff] [blame] | 36 | src/thrift/async/TAsyncProtocolProcessor.cpp |
ben-craig | 02bade1 | 2015-07-17 08:40:48 -0500 | [diff] [blame] | 37 | src/thrift/async/TConcurrentClientSyncInfo.h |
| 38 | src/thrift/async/TConcurrentClientSyncInfo.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 39 | src/thrift/concurrency/ThreadManager.cpp |
| 40 | src/thrift/concurrency/TimerManager.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 41 | src/thrift/processor/PeekProcessor.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 42 | src/thrift/protocol/TBase64Utils.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 43 | src/thrift/protocol/TDebugProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 44 | src/thrift/protocol/TJSONProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 45 | src/thrift/protocol/TMultiplexedProtocol.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 46 | src/thrift/protocol/TProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 47 | 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árez | 4750f36 | 2020-09-09 15:49:37 +0200 | [diff] [blame] | 58 | src/thrift/transport/SocketCommon.cpp |
Jim King | 5ec805b | 2015-04-26 07:52:40 -0400 | [diff] [blame] | 59 | src/thrift/server/TConnectedClient.cpp |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 60 | src/thrift/server/TServerFramework.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 61 | src/thrift/server/TSimpleServer.cpp |
| 62 | src/thrift/server/TThreadPoolServer.cpp |
| 63 | src/thrift/server/TThreadedServer.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 64 | ) |
| 65 | |
Mario Emmenlauer | 3db41fa | 2017-04-07 23:24:07 +0200 | [diff] [blame] | 66 | # These files don't work on Windows CE as there is no pipe support |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 67 | # TODO: These files won't work with UNICODE support on windows. If fixed this can be re-added. |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 68 | if (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 | ) |
| 74 | endif() |
| 75 | |
| 76 | |
Mario Emmenlauer | 3db41fa | 2017-04-07 23:24:07 +0200 | [diff] [blame] | 77 | if (WIN32) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 78 | 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 Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 90 | else() |
| 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 Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 97 | endif() |
| 98 | |
James E. King III | 1735542 | 2019-01-11 23:06:08 -0500 | [diff] [blame] | 99 | # If OpenSSL is not found or disabled just ignore the OpenSSL stuff |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 100 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 101 | list(APPEND thriftcpp_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 102 | src/thrift/transport/TSSLSocket.cpp |
| 103 | src/thrift/transport/TSSLServerSocket.cpp |
Kevin Wojniak | 2853af2 | 2021-10-20 20:56:29 -0700 | [diff] [blame] | 104 | src/thrift/transport/TWebSocketServer.h |
| 105 | src/thrift/transport/TWebSocketServer.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 106 | ) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 107 | 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 Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 118 | endif() |
| 119 | |
cyy | ca8af9b | 2019-01-11 22:13:12 +0800 | [diff] [blame] | 120 | if(UNIX) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 121 | if(ANDROID) |
| 122 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") |
| 123 | else() |
| 124 | list(APPEND SYSLIBS pthread) |
| 125 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 126 | endif() |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 127 | |
| 128 | set(thriftcpp_threads_SOURCES |
cyy | ca8af9b | 2019-01-11 22:13:12 +0800 | [diff] [blame] | 129 | 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 Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 134 | |
| 135 | # Thrift non blocking server |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 136 | set(thriftcppnb_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 137 | src/thrift/server/TNonblockingServer.cpp |
Divya Thaluru | 808d143 | 2017-08-06 16:36:36 -0700 | [diff] [blame] | 138 | src/thrift/transport/TNonblockingServerSocket.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 139 | src/thrift/async/TEvhttpServer.cpp |
| 140 | src/thrift/async/TEvhttpClientChannel.cpp |
| 141 | ) |
| 142 | |
cyy | 13e6f9e | 2019-12-12 21:13:31 +0800 | [diff] [blame] | 143 | # If OpenSSL is not found or disabled just ignore the OpenSSL stuff |
| 144 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 145 | list(APPEND thriftcppnb_SOURCES |
cyy | 13e6f9e | 2019-12-12 21:13:31 +0800 | [diff] [blame] | 146 | src/thrift/transport/TNonblockingSSLServerSocket.cpp |
| 147 | ) |
| 148 | endif() |
| 149 | |
James E. King III | 1735542 | 2019-01-11 23:06:08 -0500 | [diff] [blame] | 150 | # Thrift zlib transport |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 151 | set(thriftcppz_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 152 | src/thrift/transport/TZlibTransport.cpp |
Dave Watson | 792db4e | 2015-01-16 11:22:01 -0800 | [diff] [blame] | 153 | src/thrift/protocol/THeaderProtocol.cpp |
| 154 | src/thrift/transport/THeaderTransport.cpp |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 155 | src/thrift/protocol/THeaderProtocol.cpp |
| 156 | src/thrift/transport/THeaderTransport.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 157 | ) |
| 158 | |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 159 | # Contains the thrift specific ADD_LIBRARY_THRIFT macro |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 160 | include(ThriftMacros) |
| 161 | |
| 162 | ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 163 | target_link_libraries(thrift PUBLIC ${SYSLIBS}) |
Antonio Di Monaco | 796667b | 2016-01-04 23:05:19 +0100 | [diff] [blame] | 164 | if(WIN32) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 165 | target_link_libraries(thrift PUBLIC ws2_32) |
Antonio Di Monaco | 796667b | 2016-01-04 23:05:19 +0100 | [diff] [blame] | 166 | endif() |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 167 | ADD_PKGCONFIG_THRIFT(thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 168 | |
| 169 | if(WITH_LIBEVENT) |
Tobias Mayer | c8e46cf | 2020-02-16 10:36:11 +0100 | [diff] [blame] | 170 | find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 171 | include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 172 | |
| 173 | ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES}) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 174 | target_link_libraries(thriftnb PUBLIC thrift) |
Mario Emmenlauer | 7553fc5 | 2020-11-19 15:19:23 +0100 | [diff] [blame] | 175 | if(TARGET libevent::core AND TARGET libevent::extra) |
| 176 | # libevent was found via its cmake config, use modern style targets |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 177 | target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra) |
Mario Emmenlauer | 7553fc5 | 2020-11-19 15:19:23 +0100 | [diff] [blame] | 178 | else() |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 179 | target_link_libraries(thriftnb PUBLIC ${LIBEVENT_LIBRARIES}) |
Mario Emmenlauer | 7553fc5 | 2020-11-19 15:19:23 +0100 | [diff] [blame] | 180 | endif() |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 181 | ADD_PKGCONFIG_THRIFT(thrift-nb) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 182 | endif() |
| 183 | |
| 184 | if(WITH_ZLIB) |
| 185 | find_package(ZLIB REQUIRED) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 186 | |
| 187 | ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES}) |
Mario Emmenlauer | bdb54bc | 2021-08-31 14:00:16 +0200 | [diff] [blame] | 188 | target_link_libraries(thriftz PUBLIC thrift) |
Tobias Weihs | fe73972 | 2022-08-19 10:49:51 +0200 | [diff] [blame] | 189 | |
| 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' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 197 | ADD_PKGCONFIG_THRIFT(thrift-z) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 198 | endif() |
| 199 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 200 | if(WITH_QT5) |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 201 | add_subdirectory(src/thrift/qt) |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 202 | ADD_PKGCONFIG_THRIFT(thrift-qt5) |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 203 | endif() |
| 204 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 205 | if(MSVC) |
| 206 | add_definitions("-DUNICODE -D_UNICODE") |
| 207 | endif() |
| 208 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 209 | # Install the headers |
| 210 | install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 211 | FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc") |
| 212 | # Copy config.h file |
| 213 | install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 214 | FILES_MATCHING PATTERN "*.h") |
| 215 | |
| 216 | if(BUILD_TESTING) |
| 217 | add_subdirectory(test) |
| 218 | endif() |