forked from confluentinc/librdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
138 lines (112 loc) · 3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
cmake_minimum_required(VERSION 3.4)
project(RdKafka)
# Options. No 'RDKAFKA_' prefix to match old C++ code. {
# This option doesn't affect build in fact, only C code
# (see 'rd_kafka_version_str'). In CMake the build type feature usually used
# (like Debug, Release, etc.).
option(WITHOUT_OPTIMIZATION "Disable optimization" OFF)
option(ENABLE_DEVEL "Enable development asserts, checks, etc" OFF)
option(ENABLE_REFCNT_DEBUG "Enable refcnt debugging" OFF)
option(ENABLE_SHAREDPTR_DEBUG "Enable sharedptr debugging" OFF)
# ZLIB {
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
set(with_zlib_default ON)
else()
set(with_zlib_default OFF)
endif()
option(WITH_ZLIB "With ZLIB" ${with_zlib_default})
# }
# OpenSSL {
if(WITH_BUNDLED_SSL) # option from 'h2o' parent project
set(with_ssl_default ON)
else()
find_package(OpenSSL QUIET)
if(OpenSSL_FOUND)
set(with_ssl_default ON)
else()
set(with_ssl_default OFF)
endif()
endif()
option(WITH_SSL "With SSL" ${with_ssl_default})
# }
# SASL {
include(FindPkgConfig)
pkg_check_modules(SASL QUIET libsasl2)
if(SASL_FOUND)
set(with_sasl_default ON)
else()
set(with_sasl_default OFF)
endif()
option(WITH_SASL "With SASL" ${with_sasl_default})
# }
# }
option(RDKAFKA_BUILD_EXAMPLES "Build examples" ON)
option(RDKAFKA_BUILD_TESTS "Build tests" ON)
set(TRYCOMPILE_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/packaging/cmake/try_compile")
# In:
# * TRYCOMPILE_SRC_DIR
# Out:
# * HAVE_ATOMICS_32
# * HAVE_ATOMICS_32_SYNC
# * HAVE_ATOMICS_64
# * HAVE_ATOMICS_64_SYNC
# * HAVE_REGEX
# * HAVE_STRNDUP
# * LINK_ATOMIC
include("packaging/cmake/try_compile/rdkafka_setup.cmake")
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
# In:
# * WITHOUT_OPTIMIZATION
# * ENABLE_DEVEL
# * ENABLE_REFCNT_DEBUG
# * ENABLE_SHAREDPTR_DEBUG
# * HAVE_ATOMICS_32
# * HAVE_ATOMICS_32_SYNC
# * HAVE_ATOMICS_64
# * HAVE_ATOMICS_64_SYNC
# * WITH_ZLIB
# * WITH_SSL
# * WITH_SASL
# * HAVE_REGEX
# * HAVE_STRNDUP
configure_file(config.h.in "${GENERATED_DIR}/config.h" @ONLY)
# Installation (https://github.com/forexample/package-example) {
include(GNUInstallDirs)
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
include(CMakePackageConfigHelpers)
# In:
# * targets_export_name
# * PROJECT_NAME
configure_package_config_file(
"packaging/cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(
FILES "${project_config}"
DESTINATION "${config_install_dir}"
)
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
install(
FILES LICENSES.txt
DESTINATION "share/licenses/librdkafka"
)
# }
add_subdirectory(src)
add_subdirectory(src-cpp)
if(RDKAFKA_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(RDKAFKA_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()