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 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 20 | # Find required packages |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 21 | if(WITH_BOOSTTHREADS) |
| 22 | find_package(Boost 1.53.0 REQUIRED COMPONENTS system thread) |
| 23 | else() |
| 24 | find_package(Boost 1.53.0 REQUIRED) |
| 25 | endif() |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 26 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 27 | |
| 28 | include_directories(src) |
| 29 | |
| 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 |
| 35 | src/thrift/Thrift.cpp |
| 36 | src/thrift/TApplicationException.cpp |
| 37 | src/thrift/VirtualProfiling.cpp |
| 38 | src/thrift/concurrency/ThreadManager.cpp |
| 39 | src/thrift/concurrency/TimerManager.cpp |
| 40 | src/thrift/concurrency/Util.cpp |
| 41 | src/thrift/protocol/TDebugProtocol.cpp |
| 42 | src/thrift/protocol/TDenseProtocol.cpp |
| 43 | src/thrift/protocol/TJSONProtocol.cpp |
| 44 | src/thrift/protocol/TBase64Utils.cpp |
| 45 | src/thrift/protocol/TMultiplexedProtocol.cpp |
| 46 | src/thrift/transport/TTransportException.cpp |
| 47 | src/thrift/transport/TFDTransport.cpp |
| 48 | src/thrift/transport/TSimpleFileTransport.cpp |
| 49 | src/thrift/transport/THttpTransport.cpp |
| 50 | src/thrift/transport/THttpClient.cpp |
| 51 | src/thrift/transport/THttpServer.cpp |
| 52 | src/thrift/transport/TSocket.cpp |
| 53 | src/thrift/transport/TSocketPool.cpp |
| 54 | src/thrift/transport/TServerSocket.cpp |
| 55 | src/thrift/transport/TTransportUtils.cpp |
| 56 | src/thrift/transport/TBufferTransports.cpp |
| 57 | src/thrift/server/TServer.cpp |
| 58 | src/thrift/server/TSimpleServer.cpp |
| 59 | src/thrift/server/TThreadPoolServer.cpp |
| 60 | src/thrift/server/TThreadedServer.cpp |
| 61 | src/thrift/async/TAsyncChannel.cpp |
| 62 | src/thrift/processor/PeekProcessor.cpp |
| 63 | ) |
| 64 | |
| 65 | # This files don't work on Windows CE as there is no pipe support |
| 66 | # TODO: This files won't work with UNICODE support on windows. If fixed this can be re-added. |
| 67 | if (NOT WINCE) |
| 68 | list(APPEND thriftcpp_SOURCES |
| 69 | src/thrift/transport/TPipe.cpp |
| 70 | src/thrift/transport/TPipeServer.cpp |
| 71 | src/thrift/transport/TFileTransport.cpp |
| 72 | ) |
| 73 | endif() |
| 74 | |
| 75 | |
| 76 | if (WIN32) |
| 77 | list(APPEND thriftcpp_SOURCES |
| 78 | src/thrift/windows/TWinsockSingleton.cpp |
| 79 | src/thrift/windows/SocketPair.cpp |
| 80 | src/thrift/windows/GetTimeOfDay.cpp |
| 81 | src/thrift/windows/WinFcntl.cpp |
| 82 | ) |
| 83 | if(NOT WINCE) |
| 84 | # This file uses pipes so it currently won't work on Windows CE |
| 85 | list(APPEND thriftcpp_SOURCES |
| 86 | src/thrift/windows/OverlappedSubmissionThread.cpp |
| 87 | ) |
| 88 | endif() |
| 89 | endif() |
| 90 | |
| 91 | # If OpenSSL is not found just ignore the OpenSSL stuff |
| 92 | find_package(OpenSSL) |
| 93 | if(OPENSSL_FOUND AND WITH_OPENSSL) |
| 94 | list( APPEND thriftcpp_SOURCES |
| 95 | src/thrift/transport/TSSLSocket.cpp |
| 96 | src/thrift/transport/TSSLServerSocket.cpp |
| 97 | ) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 98 | include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 99 | list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}") |
| 100 | endif() |
| 101 | |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 102 | # WITH_*THREADS selects which threading library to use |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 103 | if(WITH_BOOSTTHREADS) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 104 | set( thriftcpp_threads_SOURCES |
| 105 | src/thrift/concurrency/BoostThreadFactory.cpp |
| 106 | src/thrift/concurrency/BoostMonitor.cpp |
| 107 | src/thrift/concurrency/BoostMutex.cpp |
| 108 | ) |
| 109 | list(APPEND SYSLIBS "${Boost_LIBRARIES}") |
| 110 | elseif(UNIX AND NOT WITH_STDTHREADS) |
| 111 | list(APPEND SYSLIBS pthread) |
| 112 | set( thriftcpp_threads_SOURCES |
| 113 | src/thrift/concurrency/PosixThreadFactory.cpp |
| 114 | src/thrift/concurrency/Mutex.cpp |
| 115 | src/thrift/concurrency/Monitor.cpp |
| 116 | ) |
| 117 | else() |
Nobuaki Sukegawa | 2825664 | 2014-12-16 03:24:37 +0900 | [diff] [blame] | 118 | if(UNIX) |
| 119 | # need pthread for multi-thread support |
| 120 | list(APPEND SYSLIBS pthread) |
| 121 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 122 | set( thriftcpp_threads_SOURCES |
| 123 | src/thrift/concurrency/StdThreadFactory.cpp |
| 124 | src/thrift/concurrency/StdMutex.cpp |
| 125 | src/thrift/concurrency/StdMonitor.cpp |
| 126 | ) |
| 127 | endif() |
| 128 | |
| 129 | # Thrift non blocking server |
| 130 | set( thriftcppnb_SOURCES |
| 131 | src/thrift/server/TNonblockingServer.cpp |
| 132 | src/thrift/async/TAsyncProtocolProcessor.cpp |
| 133 | src/thrift/async/TEvhttpServer.cpp |
| 134 | src/thrift/async/TEvhttpClientChannel.cpp |
| 135 | ) |
| 136 | |
| 137 | # Thrift zlib server |
| 138 | set( thriftcppz_SOURCES |
| 139 | src/thrift/transport/TZlibTransport.cpp |
| 140 | ) |
| 141 | |
| 142 | # Thrift Qt4 server |
| 143 | set( thriftcppqt_SOURCES |
| 144 | src/thrift/qt/TQIODeviceTransport.cpp |
| 145 | src/thrift/qt/TQTcpServer.cpp |
| 146 | ) |
| 147 | |
| 148 | # Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT |
| 149 | include(ThriftMacros) |
| 150 | |
| 151 | ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) |
| 152 | TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS}) |
| 153 | |
| 154 | if(WITH_LIBEVENT) |
| 155 | find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 156 | include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 157 | |
| 158 | ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES}) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 159 | TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 160 | endif() |
| 161 | |
| 162 | if(WITH_ZLIB) |
| 163 | find_package(ZLIB REQUIRED) |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 164 | include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 165 | |
| 166 | ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES}) |
| 167 | TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES}) |
| 168 | endif() |
| 169 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 170 | if(WITH_QT4) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 171 | set(CMAKE_AUTOMOC ON) |
| 172 | find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 173 | ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES}) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 174 | TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 175 | endif() |
| 176 | |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 177 | if(WITH_QT5) |
| 178 | # Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC |
| 179 | add_subdirectory(src/thrift/qt) |
| 180 | endif() |
| 181 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 182 | if(MSVC) |
| 183 | add_definitions("-DUNICODE -D_UNICODE") |
| 184 | endif() |
| 185 | |
| 186 | # Install the headers |
| 187 | install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 188 | FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc") |
| 189 | # Copy config.h file |
| 190 | install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}" |
| 191 | FILES_MATCHING PATTERN "*.h") |
| 192 | |
| 193 | if(BUILD_TESTING) |
| 194 | add_subdirectory(test) |
| 195 | endif() |