forked from tarantool/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (59 loc) · 2.57 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
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(kafka C)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
# Set CFLAGS
set(MY_C_FLAGS "-Wall -Wextra -Werror -std=gnu11 -fno-strict-aliasing -Wno-deprecated-declarations")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_C_FLAGS} -ggdb3")
find_package(Tarantool REQUIRED)
set(STATIC_BUILD "OFF" CACHE BOOL "Link dependencies statically?")
set(WITH_OPENSSL_1_1 "OFF" CACHE BOOL "Require openssl version >= 1.1?")
if (WITH_OPENSSL_1_1)
find_package(OpenSSL 1.1 REQUIRED)
else()
find_package(OpenSSL REQUIRED)
endif()
message("Found OPENSSL version: ${OPENSSL_VERSION}")
option(ENABLE_ASAN OFF)
if (ENABLE_ASAN)
set(LIBRDKAFKA_C_FLAGS "-fsanitize=address")
set(LIBRDKAFKA_CXX_FLAGS "-fsanitize=address")
set(LIBRDKAFKA_FLAGS "--enable-devel")
endif()
if (APPLE)
set(LIBRDKAFKA_CXX_FLAGS "${LIBRDKAFKA_CXX_FLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}")
set(LIBRDKAFKA_C_FLAGS "${LIBRDKAFKA_C_FLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}")
endif()
if(STATIC_BUILD)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a
COMMAND ./configure --enable-ssl
--disable-zstd
--prefix=${CMAKE_BINARY_DIR}/librdkafka
${LIBRDKAFKA_FLAGS}
--cc=${CMAKE_C_COMPILER}
--cxx=${CMAKE_CXX_COMPILER}
--CFLAGS=${LIBRDKAFKA_C_FLAGS}
--CXXFLAGS=${LIBRDKAFKA_CXX_FLAGS}
COMMAND $(MAKE) -j
COMMAND $(MAKE) install
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/librdkafka
COMMENT "Building librdkafka"
VERBATIM
)
add_custom_target(librdkafka.a ALL
DEPENDS ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a
)
add_library(librdkafka_static INTERFACE)
target_include_directories(librdkafka_static INTERFACE ${CMAKE_BINARY_DIR}/librdkafka/include)
target_link_libraries(librdkafka_static INTERFACE ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a)
add_dependencies(librdkafka_static librdkafka.a)
set(RDKAFKA_LIBRARY ${RDKAFKA_LIBRARY} librdkafka_static)
else()
find_package(RDKAFKA REQUIRED)
# Link RdKafka transitive dependencies manually
set(RDKAFKA_LIBRARY ${RDKAFKA_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
endif()
include_directories(${TARANTOOL_INCLUDE_DIRS})
add_subdirectory(kafka)