blob: 29caad4756f47eb4c4b28fad6035eeabb027cdea [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
James E. King IIIc9ac8d22019-01-07 16:46:45 -050020# Remove the following once lib/cpp no longer depends on boost headers:
21include(BoostMacros)
22REQUIRE_BOOST_HEADERS()
23
Pascal Bachd5f87e12014-12-12 15:59:17 +010024include_directories(src)
25
cyy8fdb7582019-02-05 02:57:21 +080026if(NOT BUILD_SHARED_LIBS)
27 add_definitions("-DTHRIFT_STATIC_DEFINE")
28endif()
29
Pascal Bachd5f87e12014-12-12 15:59:17 +010030# 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
Stefan Bolus9edecce2018-06-06 20:32:52 +020038 src/thrift/async/TAsyncProtocolProcessor.cpp
ben-craig02bade12015-07-17 08:40:48 -050039 src/thrift/async/TConcurrentClientSyncInfo.h
40 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010041 src/thrift/concurrency/ThreadManager.cpp
42 src/thrift/concurrency/TimerManager.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
Pascal Bachd5f87e12014-12-12 15:59:17 +010046 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010047 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050048 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010049 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
penenin1ab096c2020-05-18 12:27:31 -070060 src/thrift/transport/TWebSocketServer.h
61 src/thrift/transport/TWebSocketServer.cpp
Jim King5ec805b2015-04-26 07:52:40 -040062 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040063 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010064 src/thrift/server/TSimpleServer.cpp
65 src/thrift/server/TThreadPoolServer.cpp
66 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010067)
68
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020069# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040070# 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 +010071if (NOT WINCE)
72 list(APPEND thriftcpp_SOURCES
73 src/thrift/transport/TPipe.cpp
74 src/thrift/transport/TPipeServer.cpp
75 src/thrift/transport/TFileTransport.cpp
76 )
77endif()
78
79
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020080if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010081 list(APPEND thriftcpp_SOURCES
82 src/thrift/windows/TWinsockSingleton.cpp
83 src/thrift/windows/SocketPair.cpp
84 src/thrift/windows/GetTimeOfDay.cpp
85 src/thrift/windows/WinFcntl.cpp
86 )
87 if(NOT WINCE)
88 # This file uses pipes so it currently won't work on Windows CE
89 list(APPEND thriftcpp_SOURCES
90 src/thrift/windows/OverlappedSubmissionThread.cpp
91 )
92 endif()
Ben Craig7207c222015-07-06 08:40:35 -050093else()
94 # These files evaluate to nothing on Windows, so omit them from the
95 # Windows build
96 list(APPEND thriftcpp_SOURCES
97 src/thrift/VirtualProfiling.cpp
98 src/thrift/server/TServer.cpp
99 )
Pascal Bachd5f87e12014-12-12 15:59:17 +0100100endif()
101
James E. King III17355422019-01-11 23:06:08 -0500102# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
Pascal Bachd5f87e12014-12-12 15:59:17 +0100103if(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
cyyca8af9b2019-01-11 22:13:12 +0800112if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900113 if(ANDROID)
114 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
115 else()
116 list(APPEND SYSLIBS pthread)
117 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100118endif()
cyyca8af9b2019-01-11 22:13:12 +0800119set( thriftcpp_threads_SOURCES
120 src/thrift/concurrency/ThreadFactory.cpp
121 src/thrift/concurrency/Thread.cpp
122 src/thrift/concurrency/Monitor.cpp
123 src/thrift/concurrency/Mutex.cpp
124)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100125
126# Thrift non blocking server
127set( thriftcppnb_SOURCES
128 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700129 src/thrift/transport/TNonblockingServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100130 src/thrift/async/TEvhttpServer.cpp
131 src/thrift/async/TEvhttpClientChannel.cpp
132)
133
cyy13e6f9e2019-12-12 21:13:31 +0800134# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
135if(OPENSSL_FOUND AND WITH_OPENSSL)
136 list( APPEND thriftcppnb_SOURCES
137 src/thrift/transport/TNonblockingSSLServerSocket.cpp
138 )
139endif()
140
James E. King III17355422019-01-11 23:06:08 -0500141# Thrift zlib transport
Pascal Bachd5f87e12014-12-12 15:59:17 +0100142set( thriftcppz_SOURCES
143 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800144 src/thrift/protocol/THeaderProtocol.cpp
145 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900146 src/thrift/protocol/THeaderProtocol.cpp
147 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100148)
149
Pascal Bachd5f87e12014-12-12 15:59:17 +0100150# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
151include(ThriftMacros)
152
153ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100154if(WIN32)
155 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
156else()
157 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
158endif()
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500159ADD_PKGCONFIG_THRIFT(thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100160
161if(WITH_LIBEVENT)
Tobias Mayerc8e46cf2020-02-16 10:36:11 +0100162 find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900163 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100164
165 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
James E. King III278528c2019-01-11 12:17:44 -0500166 LINK_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Jim King9de9b1f2015-04-30 16:03:34 -0400167 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500168 ADD_PKGCONFIG_THRIFT(thrift-nb)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100169endif()
170
171if(WITH_ZLIB)
172 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900173 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100174
175 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400176 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
177 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500178 ADD_PKGCONFIG_THRIFT(thrift-z)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100179endif()
180
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900181if(WITH_QT5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900182 add_subdirectory(src/thrift/qt)
Joel 'Aaron' Cohen12319302019-01-25 10:42:54 -0500183 ADD_PKGCONFIG_THRIFT(thrift-qt5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900184endif()
185
Pascal Bachd5f87e12014-12-12 15:59:17 +0100186if(MSVC)
187 add_definitions("-DUNICODE -D_UNICODE")
188endif()
189
Pascal Bachd5f87e12014-12-12 15:59:17 +0100190# Install the headers
191install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
192 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
193# Copy config.h file
194install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
195 FILES_MATCHING PATTERN "*.h")
196
197if(BUILD_TESTING)
198 add_subdirectory(test)
199endif()