1- cmake_minimum_required (VERSION 3.0 FATAL_ERROR )
1+ cmake_minimum_required (VERSION 3.13 FATAL_ERROR )
22
33project (kafka C )
44
@@ -14,6 +14,8 @@ find_package(Tarantool REQUIRED)
1414
1515set (STATIC_BUILD "OFF" CACHE BOOL "Link dependencies statically?" )
1616set (WITH_OPENSSL_1_1 "OFF" CACHE BOOL "Require openssl version >= 1.1?" )
17+ set (ENABLE_ASAN "OFF" CACHE BOOL "Enable ASAN" )
18+ set (ENABLE_UBSAN "OFF" CACHE BOOL "Enable UBSAN" )
1719
1820if (WITH_OPENSSL_1_1)
1921 find_package (OpenSSL 1.1 REQUIRED )
@@ -22,14 +24,25 @@ else()
2224endif ()
2325message ("Found OPENSSL version: ${OPENSSL_VERSION} " )
2426
25- option (ENABLE_ASAN OFF )
2627if (ENABLE_ASAN)
27- set (LIBRDKAFKA_C_FLAGS "-fsanitize=address" )
28- set (LIBRDKAFKA_CXX_FLAGS "-fsanitize=address" )
29- set (LIBRDKAFKA_FLAGS "--enable-devel" )
28+ list (APPEND SANITIZER_FLAGS -fsanitize=address)
29+ endif ()
30+
31+ if (ENABLE_UBSAN)
32+ list (APPEND SANITIZER_FLAGS -fsanitize=undefined)
33+ endif ()
34+
35+ if (SANITIZER_FLAGS)
36+ list (JOIN SANITIZER_FLAGS " " SANITIZER_FLAGS)
37+ set (LIBRDKAFKA_FLAGS --enable-devel --disable-optimization)
38+ set (CMAKE_BUILD_TYPE "Debug" )
39+ set (LIBRDKAFKA_CXX_FLAGS "${SANITIZER_FLAGS} " )
40+ set (LIBRDKAFKA_C_FLAGS "${SANITIZER_FLAGS} " )
41+ set (LIBRDKAFKA_LD_FLAGS "${SANITIZER_FLAGS} " )
3042endif ()
3143
3244if (APPLE )
45+ set (LIBRDKAFKA_LD_FLAGS "${LIBRDKAFKA_LD_FLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT} " )
3346 set (LIBRDKAFKA_CXX_FLAGS "${LIBRDKAFKA_CXX_FLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT} " )
3447 set (LIBRDKAFKA_C_FLAGS "${LIBRDKAFKA_C_FLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT} " )
3548endif ()
@@ -46,6 +59,7 @@ if(STATIC_BUILD)
4659 --cxx=${CMAKE_CXX_COMPILER}
4760 --CFLAGS=${LIBRDKAFKA_C_FLAGS}
4861 --CPPFLAGS=${LIBRDKAFKA_CXX_FLAGS}
62+ --LDFLAGS=${LIBRDKAFKA_LD_FLAGS}
4963 --prefix =<INSTALL_DIR >
5064 ${LIBRDKAFKA_FLAGS}
5165
0 commit comments