Skip to content

Commit

Permalink
CMake: Generate BUILT_WITH list.
Browse files Browse the repository at this point in the history
Generated:
* GCC/CLANG/MSVC: From CMake C compiler ID.
* GXX/CLANGXX/MSVCXX: From CMake C compiler ID.
* INSTALL: From detection of GNU install program.
* PKGCONFIG: From detection of pkg-config program.
* HDRHISTOGRAM: From detection of libm library.
* ZLIB: From WITH_ZLIB option.
* ZSTD: From WITH_ZSTD option.
* LIBDL: From detection of libdl library.
* PLUGINS: From WITH_PLUGINS option.
* SSL: From WITH_SSL option.
* SASL_SCRAM: From WITH_SASL and WITH_SSL options.
* SASL_CYRUS: From WITH_SASL and WITH_SSL options and WIN32 CMake property.
* LZ4_EXT: From ENABLE_LZ4_EXT option.
* C11THREADS: From C11 threads support detection.
* CRC32C_HW: From CRC32C instruction support detection.
* SNAPPY: Hardcoded, since WITH_SNAPPY is always defined in config.h.in.
* SOCKEM: Hardcoded, since WITH_SNAPPY is always defined in config.h.in.

Not generated: GNULD and LDS
  • Loading branch information
Oxymoron79 authored and edenhill committed Mar 25, 2019
1 parent 4129740 commit 83e7eeb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 16 deletions.
76 changes: 60 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,27 @@ 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)
set(TRYCOMPILE_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/packaging/cmake/try_compile")
set(BUILT_WITH "CMAKE")

# Toolchain {
list(APPEND BUILT_WITH "${CMAKE_C_COMPILER_ID}")
list(APPEND BUILT_WITH "${CMAKE_CXX_COMPILER_ID}")
# }

# PkgConfig {
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
set(WITH_PKGCONFIG ON)
list(APPEND BUILT_WITH "PKGCONFIG")
endif()
# }

# LIBM {
include(CheckLibraryExists)
check_library_exists(m pow "" WITH_HDRHISTOGRAM)
if(WITH_HDRHISTOGRAM)
list(APPEND BUILT_WITH "HDRHISTOGRAM")
endif()
# }

# ZLIB {
Expand All @@ -32,6 +49,9 @@ else()
set(with_zlib_default OFF)
endif()
option(WITH_ZLIB "With ZLIB" ${with_zlib_default})
if(WITH_ZLIB)
list(APPEND BUILT_WITH "ZLIB")
endif()
# }

# ZSTD {
Expand All @@ -46,6 +66,9 @@ else ()
endif()
endif()
option(WITH_ZSTD "With ZSTD" ${with_zstd_default})
if(WITH_ZSTD)
list(APPEND BUILT_WITH "ZSTD")
endif()
# }

# LibDL {
Expand All @@ -55,6 +78,9 @@ try_compile(
"${TRYCOMPILE_SRC_DIR}/dlopen_test.c"
LINK_LIBRARIES "${CMAKE_DL_LIBS}"
)
if(WITH_LIBDL)
list(APPEND BUILT_WITH "LIBDL")
endif()
# }

# WITH_PLUGINS {
Expand All @@ -64,6 +90,9 @@ else()
set(with_plugins_default OFF)
endif()
option(WITH_PLUGINS "With plugin support" ${with_plugins_default})
if(WITH_PLUGINS)
list(APPEND BUILT_WITH "PLUGINS")
endif()
# }

# OpenSSL {
Expand All @@ -78,38 +107,44 @@ else()
endif()
endif()
option(WITH_SSL "With SSL" ${with_ssl_default})
if(WITH_SSL)
list(APPEND BUILT_WITH "SSL")
endif()
# }

# SASL {
if(WIN32)
set(with_sasl_default ON)
else()
include(FindPkgConfig)
pkg_check_modules(SASL libsasl2)
if(SASL_FOUND)
set(with_sasl_default ON)
else()
try_compile(
WITH_SASL_CYRUS_BOOL
"${CMAKE_CURRENT_BINARY_DIR}/try_compile"
"${TRYCOMPILE_SRC_DIR}/libsasl2_test.c"
LINK_LIBRARIES "-lsasl2"
)
if(WITH_SASL_CYRUS_BOOL)
if(PkgConfig_FOUND)
pkg_check_modules(SASL libsasl2)
if(SASL_FOUND)
set(with_sasl_default ON)
else()
try_compile(
WITH_SASL_CYRUS_BOOL
"${CMAKE_CURRENT_BINARY_DIR}/try_compile"
"${TRYCOMPILE_SRC_DIR}/libsasl2_test.c"
LINK_LIBRARIES "-lsasl2"
)
if(WITH_SASL_CYRUS_BOOL)
set(with_sasl_default ON)
set(SASL_LIBRARIES "-lsasl2")
else()
else()
set(with_sasl_default OFF)
endif()
endif()
endif()
endif()
endif()
option(WITH_SASL "With SASL" ${with_sasl_default})
if(WITH_SASL)
if(WITH_SSL)
set(WITH_SASL_SCRAM ON)
list(APPEND BUILT_WITH "SASL_SCRAM")
endif()
if(NOT WIN32)
set(WITH_SASL_CYRUS ON)
list(APPEND BUILT_WITH "SASL_CYRUS")
endif()
endif()
# }
Expand All @@ -121,14 +156,13 @@ if(ENABLE_LZ4_EXT)
find_package(LZ4)
if(LZ4_FOUND)
set(WITH_LZ4_EXT ON)
list(APPEND BUILT_WITH "LZ4_EXT")
else()
message(STATUS "Using bundled LZ4 implementation.")
endif()
endif()
# }

# }

option(RDKAFKA_BUILD_STATIC "Build static rdkafka library" OFF)
option(RDKAFKA_BUILD_EXAMPLES "Build examples" ON)
option(RDKAFKA_BUILD_TESTS "Build tests" ON)
Expand All @@ -146,8 +180,15 @@ endif(WIN32)
# * HAVE_REGEX
# * HAVE_STRNDUP
# * WITH_C11THREADS
# * WITH_CRC32C_HW
# * LINK_ATOMIC
include("packaging/cmake/try_compile/rdkafka_setup.cmake")
if(WITH_C11THREADS)
list(APPEND BUILT_WITH "C11THREADS")
endif()
if(WITH_CRC32C_HW)
list(APPEND BUILT_WITH "CRC32C_HW")
endif()

set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")

Expand All @@ -165,6 +206,9 @@ set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
# * WITH_SASL
# * HAVE_REGEX
# * HAVE_STRNDUP
list(APPEND BUILT_WITH "SNAPPY")
list(APPEND BUILT_WITH "SOCKEM")
string(REPLACE ";" " " BUILT_WITH "${BUILT_WITH}")
configure_file("packaging/cmake/config.h.in" "${GENERATED_DIR}/config.h")

# Installation (https://github.com/forexample/package-example) {
Expand Down
2 changes: 2 additions & 0 deletions packaging/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# endif
#endif

#cmakedefine01 WITH_PKGCONFIG
#cmakedefine01 WITH_HDRHISTOGRAM
#cmakedefine01 WITH_ZLIB
#cmakedefine01 WITH_ZSTD
Expand All @@ -42,3 +43,4 @@
#cmakedefine01 WITH_C11THREADS
#cmakedefine01 WITH_CRC32C_HW
#define SOLIB_EXT "${CMAKE_SHARED_LIBRARY_SUFFIX}"
#define BUILT_WITH "${BUILT_WITH}"

0 comments on commit 83e7eeb

Please sign in to comment.