blob: 90a6c28855c8857b19dc45e3d6aea1787dba7ec6 [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
26# SYSLIBS contains libraries that need to be linked to all lib targets
27set(SYSLIBS "")
28
29# Create the thrift C++ library
30set( thriftcpp_SOURCES
Pascal Bachd5f87e12014-12-12 15:59:17 +010031 src/thrift/TApplicationException.cpp
Konrad Grochowski24ea0bf2015-05-07 14:59:29 +020032 src/thrift/TOutput.cpp
Jim King79c99112015-04-30 07:10:08 -040033 src/thrift/async/TAsyncChannel.cpp
Stefan Bolus9edecce2018-06-06 20:32:52 +020034 src/thrift/async/TAsyncProtocolProcessor.cpp
ben-craig02bade12015-07-17 08:40:48 -050035 src/thrift/async/TConcurrentClientSyncInfo.h
36 src/thrift/async/TConcurrentClientSyncInfo.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010037 src/thrift/concurrency/ThreadManager.cpp
38 src/thrift/concurrency/TimerManager.cpp
39 src/thrift/concurrency/Util.cpp
Jim King79c99112015-04-30 07:10:08 -040040 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050041 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010042 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010043 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010044 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050045 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010046 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
Jim King5ec805b2015-04-26 07:52:40 -040057 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040058 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010059 src/thrift/server/TSimpleServer.cpp
60 src/thrift/server/TThreadPoolServer.cpp
61 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010062)
63
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020064# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040065# 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 +010066if (NOT WINCE)
67 list(APPEND thriftcpp_SOURCES
68 src/thrift/transport/TPipe.cpp
69 src/thrift/transport/TPipeServer.cpp
70 src/thrift/transport/TFileTransport.cpp
71 )
72endif()
73
74
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020075if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010076 list(APPEND thriftcpp_SOURCES
77 src/thrift/windows/TWinsockSingleton.cpp
78 src/thrift/windows/SocketPair.cpp
79 src/thrift/windows/GetTimeOfDay.cpp
80 src/thrift/windows/WinFcntl.cpp
81 )
82 if(NOT WINCE)
83 # This file uses pipes so it currently won't work on Windows CE
84 list(APPEND thriftcpp_SOURCES
85 src/thrift/windows/OverlappedSubmissionThread.cpp
86 )
87 endif()
Ben Craig7207c222015-07-06 08:40:35 -050088else()
89 # These files evaluate to nothing on Windows, so omit them from the
90 # Windows build
91 list(APPEND thriftcpp_SOURCES
92 src/thrift/VirtualProfiling.cpp
93 src/thrift/server/TServer.cpp
94 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010095endif()
96
James E. King III17355422019-01-11 23:06:08 -050097# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
Pascal Bachd5f87e12014-12-12 15:59:17 +010098if(OPENSSL_FOUND AND WITH_OPENSSL)
99 list( APPEND thriftcpp_SOURCES
100 src/thrift/transport/TSSLSocket.cpp
101 src/thrift/transport/TSSLServerSocket.cpp
102 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900103 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100104 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
105endif()
106
cyyca8af9b2019-01-11 22:13:12 +0800107if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900108 if(ANDROID)
109 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
110 else()
111 list(APPEND SYSLIBS pthread)
112 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100113endif()
cyyca8af9b2019-01-11 22:13:12 +0800114set( thriftcpp_threads_SOURCES
115 src/thrift/concurrency/ThreadFactory.cpp
116 src/thrift/concurrency/Thread.cpp
117 src/thrift/concurrency/Monitor.cpp
118 src/thrift/concurrency/Mutex.cpp
119)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100120
121# Thrift non blocking server
122set( thriftcppnb_SOURCES
123 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700124 src/thrift/transport/TNonblockingServerSocket.cpp
125 src/thrift/transport/TNonblockingSSLServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100126 src/thrift/async/TEvhttpServer.cpp
127 src/thrift/async/TEvhttpClientChannel.cpp
128)
129
James E. King III17355422019-01-11 23:06:08 -0500130# Thrift zlib transport
Pascal Bachd5f87e12014-12-12 15:59:17 +0100131set( thriftcppz_SOURCES
132 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800133 src/thrift/protocol/THeaderProtocol.cpp
134 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900135 src/thrift/protocol/THeaderProtocol.cpp
136 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100137)
138
Pascal Bachd5f87e12014-12-12 15:59:17 +0100139# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
140include(ThriftMacros)
141
142ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100143if(WIN32)
144 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
145else()
146 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
147endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100148
149if(WITH_LIBEVENT)
150 find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900151 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100152
153 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
James E. King III278528c2019-01-11 12:17:44 -0500154 LINK_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Jim King9de9b1f2015-04-30 16:03:34 -0400155 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100156endif()
157
158if(WITH_ZLIB)
159 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900160 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100161
162 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400163 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
164 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100165endif()
166
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900167if(WITH_QT5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900168 add_subdirectory(src/thrift/qt)
169endif()
170
Pascal Bachd5f87e12014-12-12 15:59:17 +0100171if(MSVC)
172 add_definitions("-DUNICODE -D_UNICODE")
173endif()
174
Pascal Bachd5f87e12014-12-12 15:59:17 +0100175# Install the headers
176install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
177 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
178# Copy config.h file
179install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
180 FILES_MATCHING PATTERN "*.h")
181
182if(BUILD_TESTING)
183 add_subdirectory(test)
184endif()