blob: f4e810461d343dfcd66a0046ceba2a6176165119 [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
Jim King79c99112015-04-30 07:10:08 -040039 src/thrift/processor/PeekProcessor.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050040 src/thrift/protocol/TBase64Utils.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010041 src/thrift/protocol/TDebugProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010042 src/thrift/protocol/TJSONProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010043 src/thrift/protocol/TMultiplexedProtocol.cpp
Ben Craigcfaadcc2015-07-08 20:50:33 -050044 src/thrift/protocol/TProtocol.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010045 src/thrift/transport/TTransportException.cpp
46 src/thrift/transport/TFDTransport.cpp
47 src/thrift/transport/TSimpleFileTransport.cpp
48 src/thrift/transport/THttpTransport.cpp
49 src/thrift/transport/THttpClient.cpp
50 src/thrift/transport/THttpServer.cpp
51 src/thrift/transport/TSocket.cpp
52 src/thrift/transport/TSocketPool.cpp
53 src/thrift/transport/TServerSocket.cpp
54 src/thrift/transport/TTransportUtils.cpp
55 src/thrift/transport/TBufferTransports.cpp
Jim King5ec805b2015-04-26 07:52:40 -040056 src/thrift/server/TConnectedClient.cpp
Jim King21b68522015-04-26 18:30:26 -040057 src/thrift/server/TServerFramework.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010058 src/thrift/server/TSimpleServer.cpp
59 src/thrift/server/TThreadPoolServer.cpp
60 src/thrift/server/TThreadedServer.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +010061)
62
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020063# These files don't work on Windows CE as there is no pipe support
Jim King9de9b1f2015-04-30 16:03:34 -040064# 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 +010065if (NOT WINCE)
66 list(APPEND thriftcpp_SOURCES
67 src/thrift/transport/TPipe.cpp
68 src/thrift/transport/TPipeServer.cpp
69 src/thrift/transport/TFileTransport.cpp
70 )
71endif()
72
73
Mario Emmenlauer3db41fa2017-04-07 23:24:07 +020074if (WIN32)
Pascal Bachd5f87e12014-12-12 15:59:17 +010075 list(APPEND thriftcpp_SOURCES
76 src/thrift/windows/TWinsockSingleton.cpp
77 src/thrift/windows/SocketPair.cpp
78 src/thrift/windows/GetTimeOfDay.cpp
79 src/thrift/windows/WinFcntl.cpp
80 )
81 if(NOT WINCE)
82 # This file uses pipes so it currently won't work on Windows CE
83 list(APPEND thriftcpp_SOURCES
84 src/thrift/windows/OverlappedSubmissionThread.cpp
85 )
86 endif()
Ben Craig7207c222015-07-06 08:40:35 -050087else()
88 # These files evaluate to nothing on Windows, so omit them from the
89 # Windows build
90 list(APPEND thriftcpp_SOURCES
91 src/thrift/VirtualProfiling.cpp
92 src/thrift/server/TServer.cpp
93 )
Pascal Bachd5f87e12014-12-12 15:59:17 +010094endif()
95
James E. King III17355422019-01-11 23:06:08 -050096# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
Pascal Bachd5f87e12014-12-12 15:59:17 +010097if(OPENSSL_FOUND AND WITH_OPENSSL)
98 list( APPEND thriftcpp_SOURCES
99 src/thrift/transport/TSSLSocket.cpp
100 src/thrift/transport/TSSLServerSocket.cpp
101 )
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900102 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100103 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
104endif()
105
cyyca8af9b2019-01-11 22:13:12 +0800106if(UNIX)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900107 if(ANDROID)
108 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
109 else()
110 list(APPEND SYSLIBS pthread)
111 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100112endif()
cyyca8af9b2019-01-11 22:13:12 +0800113set( thriftcpp_threads_SOURCES
114 src/thrift/concurrency/ThreadFactory.cpp
115 src/thrift/concurrency/Thread.cpp
116 src/thrift/concurrency/Monitor.cpp
117 src/thrift/concurrency/Mutex.cpp
118)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100119
120# Thrift non blocking server
121set( thriftcppnb_SOURCES
122 src/thrift/server/TNonblockingServer.cpp
Divya Thaluru808d1432017-08-06 16:36:36 -0700123 src/thrift/transport/TNonblockingServerSocket.cpp
124 src/thrift/transport/TNonblockingSSLServerSocket.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100125 src/thrift/async/TEvhttpServer.cpp
126 src/thrift/async/TEvhttpClientChannel.cpp
127)
128
James E. King III17355422019-01-11 23:06:08 -0500129# Thrift zlib transport
Pascal Bachd5f87e12014-12-12 15:59:17 +0100130set( thriftcppz_SOURCES
131 src/thrift/transport/TZlibTransport.cpp
Dave Watson792db4e2015-01-16 11:22:01 -0800132 src/thrift/protocol/THeaderProtocol.cpp
133 src/thrift/transport/THeaderTransport.cpp
Nobuaki Sukegawaca939362015-11-14 00:23:40 +0900134 src/thrift/protocol/THeaderProtocol.cpp
135 src/thrift/transport/THeaderTransport.cpp
Pascal Bachd5f87e12014-12-12 15:59:17 +0100136)
137
Pascal Bachd5f87e12014-12-12 15:59:17 +0100138# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
139include(ThriftMacros)
140
141ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
Antonio Di Monaco796667b2016-01-04 23:05:19 +0100142if(WIN32)
143 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32)
144else()
145 TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
146endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100147
148if(WITH_LIBEVENT)
149 find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900150 include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100151
152 ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
James E. King III278528c2019-01-11 12:17:44 -0500153 LINK_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
Jim King9de9b1f2015-04-30 16:03:34 -0400154 TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100155endif()
156
157if(WITH_ZLIB)
158 find_package(ZLIB REQUIRED)
Nobuaki Sukegawac444fb52015-01-02 23:16:55 +0900159 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
Pascal Bachd5f87e12014-12-12 15:59:17 +0100160
161 ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
Jim King9de9b1f2015-04-30 16:03:34 -0400162 TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
163 TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100164endif()
165
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900166if(WITH_QT5)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900167 add_subdirectory(src/thrift/qt)
168endif()
169
Pascal Bachd5f87e12014-12-12 15:59:17 +0100170if(MSVC)
171 add_definitions("-DUNICODE -D_UNICODE")
172endif()
173
Pascal Bachd5f87e12014-12-12 15:59:17 +0100174# Install the headers
175install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
176 FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
177# Copy config.h file
178install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
179 FILES_MATCHING PATTERN "*.h")
180
181if(BUILD_TESTING)
182 add_subdirectory(test)
183endif()