blob: d6107bc34fe8592d8a96eed5db34b581393984a2 [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
Pascal Bachd5f87e12014-12-12 15:59:17 +010020# Find required packages
Nobuaki Sukegawa28256642014-12-16 03:24:37 +090021if(WITH_BOOSTTHREADS)
22 find_package(Boost 1.53.0 REQUIRED COMPONENTS system thread)
23else()
24 find_package(Boost 1.53.0 REQUIRED)
25endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010026
Jim King9de9b1f2015-04-30 16:03:34 -040027include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
Pascal Bachd5f87e12014-12-12 15:59:17 +010028include_directories(src)
29
30# SYSLIBS contains libraries that need to be linked to all lib targets
31set(SYSLIBS "")
32
33# Create the thrift C++ library
34set( thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010035 src/thrift/TApplicationException.cpp
Konrad Grochowski24ea0bf2015-05-07 14:59:29 +020036 src/thrift/TOutput.cpp
Jim King79c99112015-04-30 07:10:08 -040037 src/thrift/async/TAsyncChannel.cpp
ben-craig02bade12015-07-17 08:40:48 -050038 src/thrift/async/TConcurrentClientSyncInfo.h
39 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010040 src/thrift/concurrency/ThreadManager.cpp
41 src/thrift/concurrency/TimerManager.cpp
42 src/thrift/concurrency/Util.cpp
Jim King79c99112015-04-30 07:10:08 -040043 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050044 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010045 src/thrift/protocol/TDebugProtocol.cpp
46 src/thrift/protocol/TDenseProtocol.cpp
47 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010048 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050049 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010050 src/thrift/transport/TTransportException.cpp
51 src/thrift/transport/TFDTransport.cpp
52 src/thrift/transport/TSimpleFileTransport.cpp
53 src/thrift/transport/THttpTransport.cpp
54 src/thrift/transport/THttpClient.cpp
55 src/thrift/transport/THttpServer.cpp
56 src/thrift/transport/TSocket.cpp
57 src/thrift/transport/TSocketPool.cpp
58 src/thrift/transport/TServerSocket.cpp
59 src/thrift/transport/TTransportUtils.cpp
60 src/thrift/transport/TBufferTransports.cpp
Jim King5ec805b2015-04-26 07:52:40 -040061 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040062 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010063 src/thrift/server/TSimpleServer.cpp
64 src/thrift/server/TThreadPoolServer.cpp
65 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010066)
67
68# This files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040069# 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 +010070if (NOT WINCE)
71 list(APPEND thriftcpp_SOURCES
72 src/thrift/transport/TPipe.cpp
73 src/thrift/transport/TPipeServer.cpp
74 src/thrift/transport/TFileTransport.cpp
75 )
76endif()
77
78
79if (WIN32)
80 list(APPEND thriftcpp_SOURCES
81 src/thrift/windows/TWinsockSingleton.cpp
82 src/thrift/windows/SocketPair.cpp
83 src/thrift/windows/GetTimeOfDay.cpp
84 src/thrift/windows/WinFcntl.cpp
85 )
86 if(NOT WINCE)
87 # This file uses pipes so it currently won't work on Windows CE
88 list(APPEND thriftcpp_SOURCES
89 src/thrift/windows/OverlappedSubmissionThread.cpp
90 )
91 endif()
Ben Craig7207c222015-07-06 08:40:35 -050092else()
93 # These files evaluate to nothing on Windows, so omit them from the
94 # Windows build
95 list(APPEND thriftcpp_SOURCES
96 src/thrift/VirtualProfiling.cpp
97 src/thrift/server/TServer.cpp
98 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010099endif()
100
101# If OpenSSL is not found just ignore the OpenSSL stuff
102find_package(OpenSSL)
103if(OPENSSL_FOUND AND WITH_OPENSSL)
104 list( APPEND thriftcpp_SOURCES
105 src/thrift/transport/TSSLSocket.cpp
106 src/thrift/transport/TSSLServerSocket.cpp
107 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900108 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100109 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
110endif()
111
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900112# WITH_*THREADS selects which threading library to use
Pascal Bachd5f87e12014-12-12 15:59:17 +0100113if(WITH_BOOSTTHREADS)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100114 set( thriftcpp_threads_SOURCES
115 src/thrift/concurrency/BoostThreadFactory.cpp
116 src/thrift/concurrency/BoostMonitor.cpp
117 src/thrift/concurrency/BoostMutex.cpp
118 )
119 list(APPEND SYSLIBS "${Boost_LIBRARIES}")
120elseif(UNIX AND NOT WITH_STDTHREADS)
121 list(APPEND SYSLIBS pthread)
122 set( thriftcpp_threads_SOURCES
123 src/thrift/concurrency/PosixThreadFactory.cpp
124 src/thrift/concurrency/Mutex.cpp
125 src/thrift/concurrency/Monitor.cpp
126 )
127else()
Nobuaki Sukegawa28256642014-12-16 03:24:37 +0900128 if(UNIX)
129 # need pthread for multi-thread support
130 list(APPEND SYSLIBS pthread)
131 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100132 set( thriftcpp_threads_SOURCES
133 src/thrift/concurrency/StdThreadFactory.cpp
134 src/thrift/concurrency/StdMutex.cpp
135 src/thrift/concurrency/StdMonitor.cpp
136 )
137endif()
138
139# Thrift non blocking server
140set( thriftcppnb_SOURCES
141 src/thrift/server/TNonblockingServer.cpp
142 src/thrift/async/TAsyncProtocolProcessor.cpp
143 src/thrift/async/TEvhttpServer.cpp
144 src/thrift/async/TEvhttpClientChannel.cpp
145)
146
147# Thrift zlib server
148set( thriftcppz_SOURCES
149 src/thrift/transport/TZlibTransport.cpp
150)
151
152# Thrift Qt4 server
153set( thriftcppqt_SOURCES
154 src/thrift/qt/TQIODeviceTransport.cpp
155 src/thrift/qt/TQTcpServer.cpp
156)
157
158# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
159include(ThriftMacros)
160
161ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
162TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
163
164if(WITH_LIBEVENT)
165 find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900166 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100167
168 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400169 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
170 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100171endif()
172
173if(WITH_ZLIB)
174 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900175 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100176
177 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400178 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
179 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100180endif()
181
Pascal Bachd5f87e12014-12-12 15:59:17 +0100182if(WITH_QT4)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +0900183 set(CMAKE_AUTOMOC ON)
184 find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100185 ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400186 TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
187 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftqt thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100188endif()
189
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900190if(WITH_QT5)
191 # Qt5 has its own directory to avoid conflict with Qt4 caused by CMAKE_AUTOMOC
192 add_subdirectory(src/thrift/qt)
193endif()
194
Pascal Bachd5f87e12014-12-12 15:59:17 +0100195if(MSVC)
196 add_definitions("-DUNICODE -D_UNICODE")
197endif()
198
Jim King79c99112015-04-30 07:10:08 -0400199add_definitions("-D__STDC_LIMIT_MACROS")
200
Pascal Bachd5f87e12014-12-12 15:59:17 +0100201# Install the headers
202install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
203 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
204# Copy config.h file
205install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
206 FILES_MATCHING PATTERN "*.h")
207
208if(BUILD_TESTING)
209 add_subdirectory(test)
210endif()