diff --git a/cmake/find/cyrus-sasl.cmake b/cmake/find/cyrus-sasl.cmake index 8c298af5a70..974b8148fdc 100644 --- a/cmake/find/cyrus-sasl.cmake +++ b/cmake/find/cyrus-sasl.cmake @@ -1,4 +1,10 @@ -OPTION(ENABLE_CYRUS_SASL "Enable cyrus-sasl" ${ENABLE_LIBRARIES}) +if (${ENABLE_LIBRARIES} AND ${ENABLE_KRB5}) + set (DEFAULT_ENABLE_CYRUS_SASL 1) +else() + set (DEFAULT_ENABLE_CYRUS_SASL 0) +endif() + +OPTION(ENABLE_CYRUS_SASL "Enable cyrus-sasl" ${DEFAULT_ENABLE_CYRUS_SASL}) if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/cyrus-sasl/README") message (WARNING "submodule contrib/cyrus-sasl is missing. to fix try run: \n git submodule update --init --recursive") set (ENABLE_CYRUS_SASL 0) @@ -14,4 +20,4 @@ if (ENABLE_CYRUS_SASL) endif () -message (STATUS "Using krb5=${USE_KRB5}: ${CYRUS_SASL_INCLUDE_DIR} : ${CYRUS_SASL_LIBRARY}") +message (STATUS "Using cyrus-sasl: krb5=${USE_KRB5}: ${CYRUS_SASL_INCLUDE_DIR} : ${CYRUS_SASL_LIBRARY}") diff --git a/cmake/find/krb5.cmake b/cmake/find/krb5.cmake index 4704042ec15..6b3e20d4957 100644 --- a/cmake/find/krb5.cmake +++ b/cmake/find/krb5.cmake @@ -1,9 +1,15 @@ OPTION(ENABLE_KRB5 "Enable krb5" ${ENABLE_LIBRARIES}) + if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/krb5/README") message (WARNING "submodule contrib/krb5 is missing. to fix try run: \n git submodule update --init --recursive") set (ENABLE_KRB5 0) endif () +if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux") + message (WARNING "krb5 disabled in non-Linux environments") + set (ENABLE_KRB5 0) +endif () + if (ENABLE_KRB5) set (USE_KRB5 1) diff --git a/contrib/cyrus-sasl-cmake/CMakeLists.txt b/contrib/cyrus-sasl-cmake/CMakeLists.txt index 298e6fc4cbc..f1cd7febc92 100644 --- a/contrib/cyrus-sasl-cmake/CMakeLists.txt +++ b/contrib/cyrus-sasl-cmake/CMakeLists.txt @@ -1,8 +1,8 @@ set(CYRUS_SASL_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/cyrus-sasl) -add_library(sasl2) +add_library(${CYRUS_SASL_LIBRARY}) -target_sources(sasl2 PRIVATE +target_sources(${CYRUS_SASL_LIBRARY} PRIVATE ${CYRUS_SASL_SOURCE_DIR}/plugins/gssapi.c ${CYRUS_SASL_SOURCE_DIR}/plugins/gssapiv2_init.c ${CYRUS_SASL_SOURCE_DIR}/common/plugin_common.c @@ -19,7 +19,8 @@ target_sources(sasl2 PRIVATE ${CYRUS_SASL_SOURCE_DIR}/lib/client.c ${CYRUS_SASL_SOURCE_DIR}/lib/checkpw.c ) -target_include_directories(sasl2 PUBLIC + +target_include_directories(${CYRUS_SASL_LIBRARY} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} # for config.h ${CYRUS_SASL_SOURCE_DIR}/plugins ${CYRUS_SASL_SOURCE_DIR} @@ -32,90 +33,17 @@ target_include_directories(sasl2 PUBLIC ${CYRUS_SASL_SOURCE_DIR}/utils ${CYRUS_SASL_SOURCE_DIR}/tests ) -target_compile_definitions(sasl2 PUBLIC + +target_compile_definitions(${CYRUS_SASL_LIBRARY} PUBLIC HAVE_CONFIG_H - PLUGINDIR="/usr/local/lib/sasl2" + # PLUGINDIR="/usr/local/lib/sasl2" + PLUGINDIR="" # PIC - # PLUGINDIR="../plugins/.libs" OBSOLETE_CRAM_ATTR=1 - SASLAUTHD_CONF_FILE_DEFAULT="/usr/local/etc/saslauthd.conf" - CONFIGDIR="/usr/local/lib/sasl2:/usr/local/etc/sasl2" + # SASLAUTHD_CONF_FILE_DEFAULT="/usr/local/etc/saslauthd.conf" + SASLAUTHD_CONF_FILE_DEFAULT="" + # CONFIGDIR="/usr/local/lib/sasl2:/usr/local/etc/sasl2" + CONFIGDIR="" OBSOLETE_DIGEST_ATTR=1 LIBSASL_EXPORTS=1 ) - -# add_executable(client) - -# target_sources(client PUBLIC -# ${CMAKE_CURRENT_SOURCE_DIR}/sample/client.c -# ${CMAKE_CURRENT_SOURCE_DIR}/sample/common.c -# ) - -# target_include_directories(client PUBLIC -# ${CYRUS_SASL_SOURCE_DIR}/plugins -# ${CYRUS_SASL_SOURCE_DIR} -# ${CYRUS_SASL_SOURCE_DIR}/include -# ${CYRUS_SASL_SOURCE_DIR}/lib -# ${CYRUS_SASL_SOURCE_DIR}/sasldb -# ${CYRUS_SASL_SOURCE_DIR}/common -# ${CYRUS_SASL_SOURCE_DIR}/saslauthd -# ${CYRUS_SASL_SOURCE_DIR}/sample -# ${CYRUS_SASL_SOURCE_DIR}/utils -# ${CYRUS_SASL_SOURCE_DIR}/tests -# ) -# target_compile_definitions(client PUBLIC -# HAVE_CONFIG_H -# PLUGINDIR="/usr/local/lib/sasl2" -# # PIC -# # PLUGINDIR="../plugins/.libs" -# OBSOLETE_CRAM_ATTR=1 -# SASLAUTHD_CONF_FILE_DEFAULT="/usr/local/etc/saslauthd.conf" -# CONFIGDIR="/usr/local/lib/sasl2:/usr/local/etc/sasl2" -# OBSOLETE_DIGEST_ATTR=1 -# LIBSASL_EXPORTS=1 -# ) - -# target_link_libraries(client PRIVATE -# ${PROJECT_NAME} -# dl -# krb5 -# gssapi_krb5 -# ) - -# add_executable(server) - -# target_sources(server PUBLIC -# ${CMAKE_CURRENT_SOURCE_DIR}/sample/server.c -# ${CMAKE_CURRENT_SOURCE_DIR}/sample/common.c -# ) - -# target_include_directories(server PUBLIC -# ${CYRUS_SASL_SOURCE_DIR}/plugins -# ${CYRUS_SASL_SOURCE_DIR} -# ${CYRUS_SASL_SOURCE_DIR}/include -# ${CYRUS_SASL_SOURCE_DIR}/lib -# ${CYRUS_SASL_SOURCE_DIR}/sasldb -# ${CYRUS_SASL_SOURCE_DIR}/common -# ${CYRUS_SASL_SOURCE_DIR}/saslauthd -# ${CYRUS_SASL_SOURCE_DIR}/sample -# ${CYRUS_SASL_SOURCE_DIR}/utils -# ${CYRUS_SASL_SOURCE_DIR}/tests -# ) -# target_compile_definitions(server PUBLIC -# HAVE_CONFIG_H -# PLUGINDIR="/usr/local/lib/sasl2" -# # PIC -# # PLUGINDIR="../plugins/.libs" -# OBSOLETE_CRAM_ATTR=1 -# SASLAUTHD_CONF_FILE_DEFAULT="/usr/local/etc/saslauthd.conf" -# CONFIGDIR="/usr/local/lib/sasl2:/usr/local/etc/sasl2" -# OBSOLETE_DIGEST_ATTR=1 -# LIBSASL_EXPORTS=1 -# ) - -# target_link_libraries(server PRIVATE -# krb5 -# gssapi_krb5 -# ${PROJECT_NAME} -# dl -# ) diff --git a/contrib/librdkafka-cmake/CMakeLists.txt b/contrib/librdkafka-cmake/CMakeLists.txt index 05f341121e9..f1790ff0d64 100644 --- a/contrib/librdkafka-cmake/CMakeLists.txt +++ b/contrib/librdkafka-cmake/CMakeLists.txt @@ -49,7 +49,6 @@ set(SRCS ${RDKAFKA_SOURCE_DIR}/rdkafka_request.c ${RDKAFKA_SOURCE_DIR}/rdkafka_roundrobin_assignor.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl.c - ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_cyrus.c # needed to support Kerberos, requires cyrus-sasl ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_oauthbearer.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_plain.c ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_scram.c @@ -77,13 +76,33 @@ set(SRCS ${RDKAFKA_SOURCE_DIR}/rdgz.c ) +if(${ENABLE_CYRUS_SASL}) + message (STATUS "librdkafka with SASL support") + set(SRCS + ${SRCS} + ${RDKAFKA_SOURCE_DIR}/rdkafka_sasl_cyrus.c # needed to support Kerberos, requires cyrus-sasl + ) +endif() + add_library(rdkafka ${SRCS}) target_compile_options(rdkafka PRIVATE -fno-sanitize=undefined) -target_include_directories(rdkafka SYSTEM PUBLIC include) +# target_include_directories(rdkafka SYSTEM PUBLIC include) target_include_directories(rdkafka SYSTEM PUBLIC ${RDKAFKA_SOURCE_DIR}) # Because weird logic with "include_next" is used. +target_include_directories(rdkafka SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/auxdir) # for "../config.h" target_include_directories(rdkafka SYSTEM PRIVATE ${ZSTD_INCLUDE_DIR}/common) # Because wrong path to "zstd_errors.h" is used. -target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ${ZSTD_LIBRARY} ${LIBGSASL_LIBRARY}) +target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ${ZSTD_LIBRARY}) if(OPENSSL_SSL_LIBRARY AND OPENSSL_CRYPTO_LIBRARY) target_link_libraries(rdkafka PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) endif() -# target_link_libraries(rdkafka PRIVATE ${GSASL_LIBRARIES} "-lsasl2") +if(${ENABLE_CYRUS_SASL}) + target_link_libraries(rdkafka PRIVATE ${CYRUS_SASL_LIBRARY}) + set(WITH_SASL_CYRUS 1) +endif() + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/auxdir) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" + IMMEDIATE @ONLY +) diff --git a/contrib/librdkafka-cmake/config.h b/contrib/librdkafka-cmake/config.h deleted file mode 100644 index 1780431800b..00000000000 --- a/contrib/librdkafka-cmake/config.h +++ /dev/null @@ -1,95 +0,0 @@ -// Automatically generated by ./configure -#ifndef _CONFIG_H_ -#define _CONFIG_H_ -#define ARCH "x86_64" -#define BUILT_WITH "GCC GXX PKGCONFIG OSXLD LIBDL PLUGINS ZLIB SSL SASL_CYRUS ZSTD HDRHISTOGRAM LZ4_EXT SNAPPY SOCKEM SASL_SCRAM CRC32C_HW" - -#define CPU "generic" -#define WITHOUT_OPTIMIZATION 0 -#define ENABLE_DEVEL 0 -#define ENABLE_VALGRIND 0 -#define ENABLE_REFCNT_DEBUG 0 -#define ENABLE_SHAREDPTR_DEBUG 0 -#define ENABLE_LZ4_EXT 1 -#define ENABLE_SSL 1 -#define ENABLE_SASL 1 -#define MKL_APP_NAME "librdkafka" -#define MKL_APP_DESC_ONELINE "The Apache Kafka C/C++ library" -// distro -#define SOLIB_EXT ".so" -// gcc -//#define WITH_GCC 1 -// gxx -//#define WITH_GXX 1 -// pkgconfig -//#define WITH_PKGCONFIG 1 -// install -//#define WITH_INSTALL 1 -// PIC -//#define HAVE_PIC 1 -// gnulib -//#define WITH_GNULD 1 -// __atomic_32 -#define HAVE_ATOMICS_32 1 -// __atomic_32 -#define HAVE_ATOMICS_32_ATOMIC 1 -// atomic_32 -#define ATOMIC_OP32(OP1,OP2,PTR,VAL) __atomic_ ## OP1 ## _ ## OP2(PTR, VAL, __ATOMIC_SEQ_CST) -// __atomic_64 -#define HAVE_ATOMICS_64 1 -// __atomic_64 -#define HAVE_ATOMICS_64_ATOMIC 1 -// atomic_64 -#define ATOMIC_OP64(OP1,OP2,PTR,VAL) __atomic_ ## OP1 ## _ ## OP2(PTR, VAL, __ATOMIC_SEQ_CST) -// atomic_64 -#define ATOMIC_OP(OP1,OP2,PTR,VAL) __atomic_ ## OP1 ## _ ## OP2(PTR, VAL, __ATOMIC_SEQ_CST) -// parseversion -#define RDKAFKA_VERSION_STR "0.11.4" -// parseversion -#define MKL_APP_VERSION "0.11.4" -// libdl -#define WITH_LIBDL 1 -// WITH_PLUGINS -#define WITH_PLUGINS 1 -// zlib -#define WITH_ZLIB 1 -// zstd -#define WITH_ZSTD 1 -// WITH_SNAPPY -#define WITH_SNAPPY 1 -// WITH_SOCKEM -#define WITH_SOCKEM 1 -// libssl -#define WITH_SSL 1 -// WITH_SASL_SCRAM -#define WITH_SASL_SCRAM 1 -// WITH_SASL_OAUTHBEARER -#define WITH_SASL_OAUTHBEARER 1 -#define WITH_SASL_CYRUS 1 -// crc32chw -#if !defined(__PPC__) -#define WITH_CRC32C_HW 1 -#endif -// regex -#define HAVE_REGEX 1 -// strndup -#define HAVE_STRNDUP 1 -// strerror_r -#define HAVE_STRERROR_R 1 - -#ifdef __APPLE__ -// pthread_setname_np -#define HAVE_PTHREAD_SETNAME_DARWIN 1 -#if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 101400) -#define _TTHREAD_EMULATE_TIMESPEC_GET_ -#endif - -#else -// pthread_setname_gnu -#define HAVE_PTHREAD_SETNAME_GNU 1 -#endif -// python -//#define HAVE_PYTHON 1 -// disable C11 threads for compatibility with old libc -//#define WITH_C11THREADS 1 -#endif /* _CONFIG_H_ */