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 | # SYSLIBS contains libraries that need to be linked to all lib targets |
| 31 | set(SYSLIBS "") |
| 32 | |
| 33 | # Create the thrift C++ library |
| 34 | set( thriftcpp_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 35 | src/thrift/TApplicationException.cpp |
Konrad Grochowski | 24ea0bf | 2015-05-07 14:59:29 +0200 | [diff] [blame] | 36 | src/thrift/TOutput.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 37 | src/thrift/async/TAsyncChannel.cpp |
Stefan Bolus | 9edecce | 2018-06-06 20:32:52 +0200 | [diff] [blame] | 38 | src/thrift/async/TAsyncProtocolProcessor.cpp |
ben-craig | 02bade1 | 2015-07-17 08:40:48 -0500 | [diff] [blame] | 39 | src/thrift/async/TConcurrentClientSyncInfo.h |
| 40 | src/thrift/async/TConcurrentClientSyncInfo.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 41 | src/thrift/concurrency/ThreadManager.cpp |
| 42 | src/thrift/concurrency/TimerManager.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 43 | src/thrift/processor/PeekProcessor.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 44 | src/thrift/protocol/TBase64Utils.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 45 | src/thrift/protocol/TDebugProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 46 | src/thrift/protocol/TJSONProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 47 | src/thrift/protocol/TMultiplexedProtocol.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 48 | src/thrift/protocol/TProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 49 | 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 |
penenin | 1ab096c | 2020-05-18 12:27:31 -0700 | [diff] [blame] | 60 | src/thrift/transport/TWebSocketServer.h |
| 61 | src/thrift/transport/TWebSocketServer.cpp |
David Suárez | 4750f36 | 2020-09-09 15:49:37 +0200 | [diff] [blame] | 62 | src/thrift/transport/SocketCommon.cpp |
Jim King | 5ec805b | 2015-04-26 07:52:40 -0400 | [diff] [blame] | 63 | src/thrift/server/TConnectedClient.cpp |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 64 | src/thrift/server/TServerFramework.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 65 | src/thrift/server/TSimpleServer.cpp |
| 66 | src/thrift/server/TThreadPoolServer.cpp |
| 67 | src/thrift/server/TThreadedServer.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 68 | ) |
| 69 | |
Mario Emmenlauer | 3db41fa | 2017-04-07 23:24:07 +0200 | [diff] [blame] | 70 | # 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] | 71 | # 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] | 72 | if (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 | ) |
| 78 | endif() |
| 79 | |
| 80 | |
Mario Emmenlauer | 3db41fa | 2017-04-07 23:24:07 +0200 | [diff] [blame] | 81 | if (WIN32) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 82 | 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 Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 94 | else() |
| 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 Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 101 | endif() |
| 102 | |
James E. King III | 1735542 | 2019-01-11 23:06:08 -0500 | [diff] [blame] | 103 | # If OpenSSL is not found or disabled just ignore the OpenSSL stuff |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 104 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 105 | list( APPEND thriftcpp_SOURCES |
| 106 | src/thrift/transport/TSSLSocket.cpp |
| 107 | src/thrift/transport/TSSLServerSocket.cpp |
| 108 | ) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 109 | include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 110 | list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}") |
| 111 | endif() |
| 112 | |
cyy | ca8af9b | 2019-01-11 22:13:12 +0800 | [diff] [blame] | 113 | if(UNIX) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 114 | if(ANDROID) |
| 115 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") |
| 116 | else() |
| 117 | list(APPEND SYSLIBS pthread) |
| 118 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 119 | endif() |
cyy | ca8af9b | 2019-01-11 22:13:12 +0800 | [diff] [blame] | 120 | set( 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 Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 126 | |
| 127 | # Thrift non blocking server |
| 128 | set( thriftcppnb_SOURCES |
| 129 | src/thrift/server/TNonblockingServer.cpp |
Divya Thaluru | 808d143 | 2017-08-06 16:36:36 -0700 | [diff] [blame] | 130 | src/thrift/transport/TNonblockingServerSocket.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 131 | src/thrift/async/TEvhttpServer.cpp |
| 132 | src/thrift/async/TEvhttpClientChannel.cpp |
| 133 | ) |
| 134 | |
cyy | 13e6f9e | 2019-12-12 21:13:31 +0800 | [diff] [blame] | 135 | # If OpenSSL is not found or disabled just ignore the OpenSSL stuff |
| 136 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 137 | list( APPEND thriftcppnb_SOURCES |
| 138 | src/thrift/transport/TNonblockingSSLServerSocket.cpp |
| 139 | ) |
| 140 | endif() |
| 141 | |
James E. King III | 1735542 | 2019-01-11 23:06:08 -0500 | [diff] [blame] | 142 | # Thrift zlib transport |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 143 | set( thriftcppz_SOURCES |
| 144 | src/thrift/transport/TZlibTransport.cpp |
Dave Watson | 792db4e | 2015-01-16 11:22:01 -0800 | [diff] [blame] | 145 | src/thrift/protocol/THeaderProtocol.cpp |
| 146 | src/thrift/transport/THeaderTransport.cpp |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 147 | src/thrift/protocol/THeaderProtocol.cpp |
| 148 | src/thrift/transport/THeaderTransport.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 149 | ) |
| 150 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 151 | # Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT |
| 152 | include(ThriftMacros) |
| 153 | |
| 154 | ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) |
Antonio Di Monaco | 796667b | 2016-01-04 23:05:19 +0100 | [diff] [blame] | 155 | if(WIN32) |
| 156 | TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32) |
| 157 | else() |
| 158 | TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS}) |
| 159 | endif() |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 160 | ADD_PKGCONFIG_THRIFT(thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 161 | |
| 162 | if(WITH_LIBEVENT) |
Tobias Mayer | c8e46cf | 2020-02-16 10:36:11 +0100 | [diff] [blame] | 163 | find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 164 | include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 165 | |
| 166 | ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES}) |
James E. King III | 278528c | 2019-01-11 12:17:44 -0500 | [diff] [blame] | 167 | LINK_AGAINST_THRIFT_LIBRARY(thriftnb thrift) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 168 | TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES}) |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 169 | ADD_PKGCONFIG_THRIFT(thrift-nb) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 170 | endif() |
| 171 | |
| 172 | if(WITH_ZLIB) |
| 173 | find_package(ZLIB REQUIRED) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 174 | include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 175 | |
| 176 | ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES}) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 177 | TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES}) |
| 178 | TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift) |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 179 | ADD_PKGCONFIG_THRIFT(thrift-z) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 180 | endif() |
| 181 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 182 | if(WITH_QT5) |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 183 | add_subdirectory(src/thrift/qt) |
Joel 'Aaron' Cohen | 1231930 | 2019-01-25 10:42:54 -0500 | [diff] [blame] | 184 | ADD_PKGCONFIG_THRIFT(thrift-qt5) |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 185 | endif() |
| 186 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 187 | if(MSVC) |
| 188 | add_definitions("-DUNICODE -D_UNICODE") |
| 189 | endif() |
| 190 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 191 | # Install the headers |
| 192 | install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 193 | FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc") |
| 194 | # Copy config.h file |
| 195 | install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 196 | FILES_MATCHING PATTERN "*.h") |
| 197 | |
| 198 | if(BUILD_TESTING) |
| 199 | add_subdirectory(test) |
| 200 | endif() |