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 | |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 20 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 21 | include_directories(src) |
| 22 | |
| 23 | # SYSLIBS contains libraries that need to be linked to all lib targets |
| 24 | set(SYSLIBS "") |
| 25 | |
| 26 | # Create the thrift C++ library |
| 27 | set( thriftcpp_SOURCES |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 28 | src/thrift/TApplicationException.cpp |
Konrad Grochowski | 24ea0bf | 2015-05-07 14:59:29 +0200 | [diff] [blame] | 29 | src/thrift/TOutput.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 30 | src/thrift/async/TAsyncChannel.cpp |
ben-craig | 02bade1 | 2015-07-17 08:40:48 -0500 | [diff] [blame] | 31 | src/thrift/async/TConcurrentClientSyncInfo.h |
| 32 | src/thrift/async/TConcurrentClientSyncInfo.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 33 | src/thrift/concurrency/ThreadManager.cpp |
| 34 | src/thrift/concurrency/TimerManager.cpp |
| 35 | src/thrift/concurrency/Util.cpp |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 36 | src/thrift/processor/PeekProcessor.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 37 | src/thrift/protocol/TBase64Utils.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 38 | src/thrift/protocol/TDebugProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 39 | src/thrift/protocol/TJSONProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 40 | src/thrift/protocol/TMultiplexedProtocol.cpp |
Ben Craig | cfaadcc | 2015-07-08 20:50:33 -0500 | [diff] [blame] | 41 | src/thrift/protocol/TProtocol.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 42 | src/thrift/transport/TTransportException.cpp |
| 43 | src/thrift/transport/TFDTransport.cpp |
| 44 | src/thrift/transport/TSimpleFileTransport.cpp |
| 45 | src/thrift/transport/THttpTransport.cpp |
| 46 | src/thrift/transport/THttpClient.cpp |
| 47 | src/thrift/transport/THttpServer.cpp |
| 48 | src/thrift/transport/TSocket.cpp |
| 49 | src/thrift/transport/TSocketPool.cpp |
| 50 | src/thrift/transport/TServerSocket.cpp |
| 51 | src/thrift/transport/TTransportUtils.cpp |
| 52 | src/thrift/transport/TBufferTransports.cpp |
Jim King | 5ec805b | 2015-04-26 07:52:40 -0400 | [diff] [blame] | 53 | src/thrift/server/TConnectedClient.cpp |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 54 | src/thrift/server/TServerFramework.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 55 | src/thrift/server/TSimpleServer.cpp |
| 56 | src/thrift/server/TThreadPoolServer.cpp |
| 57 | src/thrift/server/TThreadedServer.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 58 | ) |
| 59 | |
| 60 | # This 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] | 61 | # 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] | 62 | if (NOT WINCE) |
| 63 | list(APPEND thriftcpp_SOURCES |
| 64 | src/thrift/transport/TPipe.cpp |
| 65 | src/thrift/transport/TPipeServer.cpp |
| 66 | src/thrift/transport/TFileTransport.cpp |
| 67 | ) |
| 68 | endif() |
| 69 | |
| 70 | |
| 71 | if (WIN32) |
| 72 | list(APPEND thriftcpp_SOURCES |
| 73 | src/thrift/windows/TWinsockSingleton.cpp |
| 74 | src/thrift/windows/SocketPair.cpp |
| 75 | src/thrift/windows/GetTimeOfDay.cpp |
| 76 | src/thrift/windows/WinFcntl.cpp |
| 77 | ) |
| 78 | if(NOT WINCE) |
| 79 | # This file uses pipes so it currently won't work on Windows CE |
| 80 | list(APPEND thriftcpp_SOURCES |
| 81 | src/thrift/windows/OverlappedSubmissionThread.cpp |
| 82 | ) |
| 83 | endif() |
Ben Craig | 7207c22 | 2015-07-06 08:40:35 -0500 | [diff] [blame] | 84 | else() |
| 85 | # These files evaluate to nothing on Windows, so omit them from the |
| 86 | # Windows build |
| 87 | list(APPEND thriftcpp_SOURCES |
| 88 | src/thrift/VirtualProfiling.cpp |
| 89 | src/thrift/server/TServer.cpp |
| 90 | ) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 91 | endif() |
| 92 | |
| 93 | # If OpenSSL is not found just ignore the OpenSSL stuff |
| 94 | find_package(OpenSSL) |
| 95 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 96 | list( APPEND thriftcpp_SOURCES |
| 97 | src/thrift/transport/TSSLSocket.cpp |
| 98 | src/thrift/transport/TSSLServerSocket.cpp |
| 99 | ) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 100 | include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 101 | list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}") |
| 102 | endif() |
| 103 | |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 104 | # WITH_*THREADS selects which threading library to use |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 105 | if(WITH_BOOSTTHREADS) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 106 | set( thriftcpp_threads_SOURCES |
| 107 | src/thrift/concurrency/BoostThreadFactory.cpp |
| 108 | src/thrift/concurrency/BoostMonitor.cpp |
| 109 | src/thrift/concurrency/BoostMutex.cpp |
| 110 | ) |
| 111 | list(APPEND SYSLIBS "${Boost_LIBRARIES}") |
| 112 | elseif(UNIX AND NOT WITH_STDTHREADS) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 113 | if(ANDROID) |
| 114 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") |
| 115 | else() |
| 116 | list(APPEND SYSLIBS pthread) |
| 117 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 118 | set( thriftcpp_threads_SOURCES |
| 119 | src/thrift/concurrency/PosixThreadFactory.cpp |
| 120 | src/thrift/concurrency/Mutex.cpp |
| 121 | src/thrift/concurrency/Monitor.cpp |
| 122 | ) |
| 123 | else() |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 124 | if(UNIX) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 125 | if(ANDROID) |
| 126 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") |
| 127 | else() |
| 128 | list(APPEND SYSLIBS pthread) |
| 129 | endif() |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 130 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 131 | set( thriftcpp_threads_SOURCES |
| 132 | src/thrift/concurrency/StdThreadFactory.cpp |
| 133 | src/thrift/concurrency/StdMutex.cpp |
| 134 | src/thrift/concurrency/StdMonitor.cpp |
| 135 | ) |
| 136 | endif() |
| 137 | |
| 138 | # Thrift non blocking server |
| 139 | set( thriftcppnb_SOURCES |
| 140 | src/thrift/server/TNonblockingServer.cpp |
| 141 | src/thrift/async/TAsyncProtocolProcessor.cpp |
| 142 | src/thrift/async/TEvhttpServer.cpp |
| 143 | src/thrift/async/TEvhttpClientChannel.cpp |
| 144 | ) |
| 145 | |
| 146 | # Thrift zlib server |
| 147 | set( thriftcppz_SOURCES |
| 148 | src/thrift/transport/TZlibTransport.cpp |
Dave Watson | 792db4e | 2015-01-16 11:22:01 -0800 | [diff] [blame] | 149 | src/thrift/protocol/THeaderProtocol.cpp |
| 150 | src/thrift/transport/THeaderTransport.cpp |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 151 | src/thrift/protocol/THeaderProtocol.cpp |
| 152 | src/thrift/transport/THeaderTransport.cpp |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 153 | ) |
| 154 | |
| 155 | # Thrift Qt4 server |
| 156 | set( thriftcppqt_SOURCES |
| 157 | src/thrift/qt/TQIODeviceTransport.cpp |
| 158 | src/thrift/qt/TQTcpServer.cpp |
| 159 | ) |
| 160 | |
| 161 | # Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT |
| 162 | include(ThriftMacros) |
| 163 | |
| 164 | ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) |
Antonio Di Monaco | 796667b | 2016-01-04 23:05:19 +0100 | [diff] [blame] | 165 | if(WIN32) |
| 166 | TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32) |
| 167 | else() |
| 168 | TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS}) |
| 169 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 170 | |
| 171 | if(WITH_LIBEVENT) |
| 172 | find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 173 | include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 174 | |
| 175 | ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES}) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 176 | TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES}) |
| 177 | TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 178 | endif() |
| 179 | |
| 180 | if(WITH_ZLIB) |
| 181 | find_package(ZLIB REQUIRED) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 182 | include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 183 | |
| 184 | ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES}) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 185 | TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES}) |
| 186 | TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 187 | endif() |
| 188 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 189 | if(WITH_QT4) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 190 | set(CMAKE_AUTOMOC ON) |
| 191 | find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 192 | ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES}) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 193 | TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork) |
| 194 | TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftqt thrift) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 195 | endif() |
| 196 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 197 | if(WITH_QT5) |
| 198 | # Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC |
| 199 | add_subdirectory(src/thrift/qt) |
| 200 | endif() |
| 201 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 202 | if(MSVC) |
| 203 | add_definitions("-DUNICODE -D_UNICODE") |
| 204 | endif() |
| 205 | |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 206 | add_definitions("-D__STDC_LIMIT_MACROS") |
| 207 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 208 | # Install the headers |
| 209 | install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 210 | FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc") |
| 211 | # Copy config.h file |
| 212 | install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 213 | FILES_MATCHING PATTERN "*.h") |
| 214 | |
| 215 | if(BUILD_TESTING) |
| 216 | add_subdirectory(test) |
| 217 | endif() |