blob: 218f7dd7d18397a4d935e218b2402482344f7b85 [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
21find_package(GLIB REQUIRED COMPONENTS gobject)
22include_directories(${GLIB_INCLUDE_DIRS})
23
24include_directories(src)
25
26# SYSLIBS contains libraries that need to be linked to all lib targets
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020027list(APPEND SYSLIBS ${GLIB_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES})
Pascal Bachd5f87e12014-12-12 15:59:17 +010028
29# Create the thrift C glib library
30set(thrift_c_glib_SOURCES
31 src/thrift/c_glib/thrift.c
32 src/thrift/c_glib/thrift_struct.c
33 src/thrift/c_glib/thrift_application_exception.c
zeshuai007c80b8bb2020-07-23 09:43:41 +080034 src/thrift/c_glib/thrift_configuration.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010035 src/thrift/c_glib/processor/thrift_processor.c
36 src/thrift/c_glib/processor/thrift_dispatch_processor.c
Gonzalo Aguilar Delgado87ad2bc2017-09-15 12:26:02 +020037 src/thrift/c_glib/processor/thrift_multiplexed_processor.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010038 src/thrift/c_glib/protocol/thrift_protocol.c
39 src/thrift/c_glib/protocol/thrift_protocol_factory.c
Gonzalo Aguilar Delgado87ad2bc2017-09-15 12:26:02 +020040 src/thrift/c_glib/protocol/thrift_protocol_decorator.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010041 src/thrift/c_glib/protocol/thrift_binary_protocol.c
Gonzalo Aguilar Delgado87ad2bc2017-09-15 12:26:02 +020042 src/thrift/c_glib/protocol/thrift_stored_message_protocol.c
cyya6a3a782019-02-07 22:27:33 +080043 src/thrift/c_glib/protocol/thrift_multiplexed_protocol.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010044 src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
Chandler May6dde90b2016-01-10 06:01:10 +000045 src/thrift/c_glib/protocol/thrift_compact_protocol.c
46 src/thrift/c_glib/protocol/thrift_compact_protocol_factory.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010047 src/thrift/c_glib/transport/thrift_transport.c
48 src/thrift/c_glib/transport/thrift_transport_factory.c
49 src/thrift/c_glib/transport/thrift_buffered_transport_factory.c
50 src/thrift/c_glib/transport/thrift_framed_transport_factory.c
51 src/thrift/c_glib/transport/thrift_socket.c
52 src/thrift/c_glib/transport/thrift_server_transport.c
53 src/thrift/c_glib/transport/thrift_server_socket.c
54 src/thrift/c_glib/transport/thrift_buffered_transport.c
Simon Southe71f20c2016-02-11 06:52:37 -050055 src/thrift/c_glib/transport/thrift_fd_transport.c
Pascal Bachd5f87e12014-12-12 15:59:17 +010056 src/thrift/c_glib/transport/thrift_framed_transport.c
57 src/thrift/c_glib/transport/thrift_memory_buffer.c
58 src/thrift/c_glib/server/thrift_server.c
59 src/thrift/c_glib/server/thrift_simple_server.c
60)
61
zeshuai007037753e2020-11-30 11:16:10 +080062set(thrift_c_glib_zlib_SOURCES
63 src/thrift/c_glib/thrift.c
64 src/thrift/c_glib/thrift_struct.c
65 src/thrift/c_glib/thrift_application_exception.c
66 src/thrift/c_glib/thrift_configuration.c
67 src/thrift/c_glib/transport/thrift_transport.c
68 src/thrift/c_glib/transport/thrift_transport_factory.c
69 src/thrift/c_glib/transport/thrift_zlib_transport.c
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020070 src/thrift/c_glib/transport/thrift_zlib_transport_factory.c
zeshuai007037753e2020-11-30 11:16:10 +080071)
72
James E. King, III36628a22017-02-13 15:25:41 -050073# If OpenSSL is not found just ignore the OpenSSL stuff
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020074if(OPENSSL_FOUND AND WITH_OPENSSL)
Kevin Wojniakdbb95e42020-01-25 12:37:23 -080075 list(APPEND thrift_c_glib_SOURCES
James E. King, III36628a22017-02-13 15:25:41 -050076 src/thrift/c_glib/transport/thrift_ssl_socket.c
77 )
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020078 if(TARGET OpenSSL::SSL OR TARGET OpenSSL::Crypto)
79 if(TARGET OpenSSL::SSL)
80 list(APPEND SYSLIBS OpenSSL::SSL)
81 endif()
82 if(TARGET OpenSSL::Crypto)
83 list(APPEND SYSLIBS OpenSSL::Crypto)
84 endif()
85 else()
86 include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
87 list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
88 endif()
James E. King, III36628a22017-02-13 15:25:41 -050089endif()
90
91
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020092# Contains the thrift specific ADD_LIBRARY_THRIFT macro
Pascal Bachd5f87e12014-12-12 15:59:17 +010093include(ThriftMacros)
94
95ADD_LIBRARY_THRIFT(thrift_c_glib ${thrift_c_glib_SOURCES})
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +020096target_link_libraries(thrift_c_glib PUBLIC ${SYSLIBS})
Pascal Bachd5f87e12014-12-12 15:59:17 +010097
zeshuai007037753e2020-11-30 11:16:10 +080098# If Zlib is not found just ignore the Zlib stuff
99if(WITH_ZLIB)
100 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
101 ADD_LIBRARY_THRIFT(thrift_c_glib_zlib ${thrift_c_glib_zlib_SOURCES})
Mario Emmenlauerbdb54bc2021-08-31 14:00:16 +0200102 target_link_libraries(thrift_c_glib_zlib ${SYSLIBS} ${ZLIB_LIBRARIES})
103 target_link_libraries(thrift_c_glib_zlib thrift_c_glib)
zeshuai007037753e2020-11-30 11:16:10 +0800104endif()
105
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106# Install the headers
107install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
108 FILES_MATCHING PATTERN "*.h")
Chandler Mayccd998a2016-01-10 06:01:10 +0000109# Copy config.h file
110install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
111 FILES_MATCHING PATTERN "*.h")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100112
113if(BUILD_TESTING)
114 add_subdirectory(test)
115endif()