mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-28 09:12:39 +00:00
Adding CMAKE subdir
This commit is contained in:
57
cmake/CppKafkaConfig.cmake
Normal file
57
cmake/CppKafkaConfig.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||
####### Any changes to this file will be overwritten by the next CMake run ####
|
||||
####### The input file was config.cmake.in ########
|
||||
|
||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
||||
|
||||
macro(set_and_check _var _file)
|
||||
set(${_var} "${_file}")
|
||||
if(NOT EXISTS "${_file}")
|
||||
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_required_components _NAME)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(NOT ${_NAME}_${comp}_FOUND)
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
####################################################################################
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# Add FindRdKafka.cmake
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(RDKAFKA_MIN_VERSION_HEX "0x00090400")
|
||||
|
||||
# Find boost optional
|
||||
find_dependency(Boost REQUIRED)
|
||||
|
||||
# Try to find the RdKafka configuration file if present.
|
||||
# This will search default system locations as well as RdKafka_ROOT and RdKafka_DIR paths if specified.
|
||||
find_package(RdKafka QUIET CONFIG)
|
||||
set(RDKAFKA_TARGET_IMPORTS ${RdKafka_FOUND})
|
||||
if (NOT RdKafka_FOUND)
|
||||
find_dependency(RdKafka REQUIRED MODULE)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CppKafkaTargets.cmake")
|
||||
|
||||
# Export 'CppKafka_ROOT'
|
||||
set_and_check(CppKafka_ROOT "${PACKAGE_PREFIX_DIR}")
|
||||
|
||||
# Export 'CppKafka_INSTALL_INCLUDE_DIR'
|
||||
set_and_check(CppKafka_INSTALL_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
|
||||
|
||||
# Export 'CppKafka_INSTALL_LIB_DIR'
|
||||
set_and_check(CppKafka_INSTALL_LIB_DIR "${PACKAGE_PREFIX_DIR}/lib")
|
||||
|
||||
# Validate installed components
|
||||
check_required_components("CppKafka")
|
||||
133
cmake/FindMySQL.cmake
Normal file
133
cmake/FindMySQL.cmake
Normal file
@@ -0,0 +1,133 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#.rst:
|
||||
# FindMySQL
|
||||
# -------
|
||||
#
|
||||
# Find MySQL Runtime
|
||||
#
|
||||
# This will define the following variables::
|
||||
#
|
||||
# MYSQL_FOUND - True if the system has the libraries
|
||||
# MYSQL_INCLUDE_DIRS - where to find the headers
|
||||
# MYSQL_LIBRARIES - where to find the libraries
|
||||
# MYSQL_DEFINITIONS - compile definitons
|
||||
#
|
||||
# Hints:
|
||||
# Set ``MYSQL_ROOT_DIR`` to the root directory of an installation.
|
||||
#
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_MYSQL QUIET mysqlclient)
|
||||
pkg_check_modules(PC_MARIADB QUIET mariadb)
|
||||
|
||||
SET(BINDIR32_ENV_NAME "ProgramFiles(x86)")
|
||||
SET(BINDIR32 $ENV{${BINDIR32_ENV_NAME}})
|
||||
|
||||
find_path(MYSQL_INCLUDE_DIR mysql.h
|
||||
HINTS
|
||||
${MYSQL_ROOT_DIR}/include
|
||||
${MYSQL_ROOT_INCLUDE_DIRS}
|
||||
PATHS
|
||||
${PC_MYSQL_INCLUDE_DIRS}
|
||||
${PC_MARIADB_INCLUDE_DIRS}
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/mysql/mysql/include
|
||||
/usr/local/mysql/include
|
||||
$ENV{MYSQL_INCLUDE_DIR}
|
||||
$ENV{MYSQL_DIR}/include
|
||||
$ENV{ProgramFiles}/MySQL/*/include
|
||||
${BINDIR32}/MySQL/*/include
|
||||
$ENV{SystemDrive}/MySQL/*/include
|
||||
$ENV{MARIADB_INCLUDE_DIR}
|
||||
$ENV{MARIADB_DIR}/include
|
||||
${MARIADB_INCLUDE_DIR}
|
||||
${MARIADB_DIR}/include
|
||||
PATH_SUFFIXES
|
||||
mysql
|
||||
mariadb
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(libsuffixDist debug)
|
||||
set(libsuffixBuild Debug)
|
||||
else (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(libsuffixDist opt)
|
||||
set(libsuffixBuild Release)
|
||||
set(WIN_MYSQL_DEFINITONS " -DDBUG_OFF")
|
||||
endif (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
find_library(MYSQL_LIBRARY NAMES mysqlclient
|
||||
HINTS
|
||||
${MYSQL_ROOT_DIR}/lib
|
||||
${MYSQL_ROOT_LIBRARY_DIRS}
|
||||
PATHS
|
||||
${PC_MYSQL_LIBRARY_DIRS}
|
||||
${PC_MARIADB_LIBRARY_DIRS}
|
||||
$ENV{MYSQL_DIR}/lib
|
||||
$ENV{MYSQL_DIR}/libmysql
|
||||
$ENV{MYSQL_DIR}/client
|
||||
$ENV{ProgramFiles}/MySQL/*/lib
|
||||
${BINDIR32}/MySQL/*/lib
|
||||
$ENV{SystemDrive}/MySQL/*/lib
|
||||
PATH_SUFFIXES
|
||||
vs12
|
||||
vs11
|
||||
vs10
|
||||
${libsuffixDist}
|
||||
${libsuffixBuild}
|
||||
)
|
||||
else()
|
||||
find_library(MYSQL_LIBRARY NAMES mysqlclient mysqlclient_r mariadbclient
|
||||
HINTS
|
||||
${MYSQL_ROOT_DIR}/lib
|
||||
${MYSQL_ROOT_LIBRARY_DIRS}
|
||||
PATHS
|
||||
${PC_MYSQL_LIBRARY_DIRS}
|
||||
${PC_MARIADB_LIBRARY_DIRS}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/usr/local/mysql/lib
|
||||
/opt/mysql/mysql/lib
|
||||
$ENV{MYSQL_DIR}/libmysql_r/.libs
|
||||
$ENV{MYSQL_DIR}/lib
|
||||
${MYSQL_DIR}/lib
|
||||
PATH_SUFFIXES
|
||||
mysql
|
||||
mariadb
|
||||
)
|
||||
endif()
|
||||
|
||||
set(MYSQL_VERSION ${PC_MYSQL_VERSION})
|
||||
|
||||
find_package_handle_standard_args(MYSQL
|
||||
FOUND_VAR MYSQL_FOUND
|
||||
REQUIRED_VARS
|
||||
MYSQL_INCLUDE_DIR
|
||||
MYSQL_LIBRARY
|
||||
VERSION_VAR MYSQL_VERSION
|
||||
)
|
||||
|
||||
if(MYSQL_FOUND)
|
||||
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
|
||||
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIR})
|
||||
set(MYSQL_DEFINITIONS "${PC_MYSQL_CFLAGS_OTHER}${WIN_MYSQL_DEFINITONS}")
|
||||
endif()
|
||||
|
||||
if(MYSQL_FOUND AND NOT TARGET MySQL::client)
|
||||
add_library(MySQL::client UNKNOWN IMPORTED)
|
||||
set_target_properties(MySQL::client PROPERTIES
|
||||
IMPORTED_LOCATION "${MYSQL_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${PC_MYSQL_CFLAGS_OTHER}${WIN_MYSQL_DEFINITONS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
MYSQL_LIBRARY
|
||||
MYSQL_INCLUDE_DIR
|
||||
)
|
||||
212
cmake/FindPostgreSQL.cmake
Normal file
212
cmake/FindPostgreSQL.cmake
Normal file
@@ -0,0 +1,212 @@
|
||||
# TODO(Bjoe) This is taken from cmake 3.10. For poco we need some changes here. Maybe we create an issue on cmake project
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#.rst:
|
||||
# FindPostgreSQL
|
||||
# --------------
|
||||
#
|
||||
# Find the PostgreSQL installation.
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
|
||||
# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
|
||||
# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries
|
||||
# PostgreSQL_VERSION - the version of PostgreSQL found (since CMake 2.8.8)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# History:
|
||||
# This module is derived from the module originally found in the VTK source tree.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# Note:
|
||||
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
|
||||
# version mumber of the implementation of PostgreSQL.
|
||||
# In Windows the default installation of PostgreSQL uses that as part of the path.
|
||||
# E.g C:\Program Files\PostgreSQL\8.4.
|
||||
# Currently, the following version numbers are known to this module:
|
||||
# "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
|
||||
#
|
||||
# To use this variable just do something like this:
|
||||
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
|
||||
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
|
||||
# This will mean that the versions you set here will be found first in the order
|
||||
# specified before the default ones are searched.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# You may need to manually set:
|
||||
# PostgreSQL_ROOT_DIR - that points to the root of where you have installed PostgreSQL
|
||||
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
|
||||
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
|
||||
# If FindPostgreSQL.cmake cannot find the include files or the library files.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# The following variables are set if PostgreSQL is found:
|
||||
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
|
||||
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
||||
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
||||
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# If you have installed PostgreSQL in a non-standard location.
|
||||
# (Please note that in the following comments, it is assumed that <Your Path>
|
||||
# points to the root directory of the include directory of PostgreSQL.)
|
||||
# Then you have three options.
|
||||
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
|
||||
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
|
||||
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
|
||||
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
|
||||
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
|
||||
# 3) Set an environment variable called ${PostgreSQL_ROOT} / ${PostgreSQL_ROOT_DIR} that points to the root of where you have
|
||||
# installed PostgreSQL, e.g. <Your Path>.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
|
||||
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
|
||||
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
|
||||
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
|
||||
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
|
||||
|
||||
|
||||
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
|
||||
"10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
|
||||
|
||||
# Define additional search paths for root directories.
|
||||
set(PostgreSQL_ROOT_DIRECTORIES
|
||||
ENV PostgreSQL_ROOT
|
||||
${PostgreSQL_ROOT}
|
||||
${PostgreSQL_ROOT_DIR}
|
||||
)
|
||||
foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})
|
||||
if(WIN32)
|
||||
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/lib")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/include")
|
||||
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/include/server")
|
||||
endif()
|
||||
if(UNIX)
|
||||
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"pgsql-${suffix}/lib")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"pgsql-${suffix}/include")
|
||||
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"postgresql/${suffix}/server"
|
||||
"pgsql-${suffix}/include/server")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND PostgreSQL_ROOT_DIRECTORIES
|
||||
"/usr")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"include/postgresql")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Look for an installation.
|
||||
#
|
||||
find_path(PostgreSQL_INCLUDE_DIR
|
||||
NAMES libpq-fe.h
|
||||
HINTS
|
||||
${PostgreSQL_ROOT_INCLUDE_DIRS}
|
||||
PATHS
|
||||
# Look in other places.
|
||||
${PostgreSQL_ROOT_DIRECTORIES}
|
||||
PATH_SUFFIXES
|
||||
pgsql
|
||||
postgresql
|
||||
include
|
||||
${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# Help the user find it if we cannot.
|
||||
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||
)
|
||||
|
||||
# TODO(Bjoe) It is not needed to build an PostgreSQL client. Maybe create an issue on cmake project
|
||||
# find_path(PostgreSQL_TYPE_INCLUDE_DIR
|
||||
# NAMES catalog/pg_type.h
|
||||
# PATHS
|
||||
# # Look in other places.
|
||||
# ${PostgreSQL_ROOT_DIRECTORIES}
|
||||
# PATH_SUFFIXES
|
||||
# postgresql
|
||||
# pgsql/server
|
||||
# postgresql/server
|
||||
# include/server
|
||||
# ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# # Help the user find it if we cannot.
|
||||
# DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||
# )
|
||||
|
||||
# The PostgreSQL library.
|
||||
set(PostgreSQL_LIBRARY_TO_FIND pq)
|
||||
# Setting some more prefixes for the library
|
||||
set(PostgreSQL_LIB_PREFIX "")
|
||||
if(WIN32)
|
||||
set(PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
|
||||
set(PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
|
||||
endif()
|
||||
|
||||
find_library(PostgreSQL_LIBRARY
|
||||
NAMES ${PostgreSQL_LIBRARY_TO_FIND}
|
||||
HINTS
|
||||
${PostgreSQL_ROOT_LIBRARY_DIRS}
|
||||
PATHS
|
||||
${PostgreSQL_ROOT_DIRECTORIES}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# Help the user find it if we cannot.
|
||||
DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
|
||||
)
|
||||
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
||||
|
||||
if(PostgreSQL_INCLUDE_DIR)
|
||||
# Some platforms include multiple pg_config.hs for multi-lib configurations
|
||||
# This is a temporary workaround. A better solution would be to compile
|
||||
# a dummy c file and extract the value of the symbol.
|
||||
file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
|
||||
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
|
||||
if(EXISTS "${_PG_CONFIG_HEADER}")
|
||||
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
|
||||
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
||||
if(pgsql_version_str)
|
||||
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
|
||||
"\\1" PostgreSQL_VERSION "${pgsql_version_str}")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
unset(pgsql_version_str)
|
||||
endif()
|
||||
|
||||
# Did we find anything?
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
PostgreSQL
|
||||
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR #PostgreSQL_TYPE_INCLUDE_DIR
|
||||
VERSION_VAR PostgreSQL_VERSION
|
||||
)
|
||||
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
||||
|
||||
# Now try to get the include and library path.
|
||||
if(PostgreSQL_FOUND)
|
||||
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ) #${PostgreSQL_TYPE_INCLUDE_DIR} )
|
||||
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
|
||||
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PostgreSQL_FOUND AND NOT TARGET PostgreSQL::PostgreSQL)
|
||||
add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED)
|
||||
set_target_properties(PostgreSQL::PostgreSQL PROPERTIES
|
||||
IMPORTED_LOCATION "${PostgreSQL_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_LIBRARY ) #PostgreSQL_TYPE_INCLUDE_DIR
|
||||
73
cmake/FindRdKafka.cmake
Normal file
73
cmake/FindRdKafka.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# This find module helps find the RdKafka module. It exports the following variables:
|
||||
# - RdKafka_INCLUDE_DIR : The directory where rdkafka.h is located.
|
||||
# - RdKafka_LIBNAME : The name of the library, i.e. librdkafka.a, librdkafka.so, etc.
|
||||
# - RdKafka_LIBRARY_PATH : The full library path i.e. <path_to_binaries>/${RdKafka_LIBNAME}
|
||||
# - RdKafka::rdkafka : Imported library containing all above properties set.
|
||||
|
||||
if (CPPKAFKA_RDKAFKA_STATIC_LIB)
|
||||
set(RDKAFKA_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
|
||||
set(RDKAFKA_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(RDKAFKA_LIBRARY_TYPE STATIC)
|
||||
else()
|
||||
set(RDKAFKA_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
|
||||
set(RDKAFKA_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
set(RDKAFKA_LIBRARY_TYPE SHARED)
|
||||
endif()
|
||||
|
||||
set(RdKafka_LIBNAME ${RDKAFKA_PREFIX}rdkafka${RDKAFKA_SUFFIX})
|
||||
|
||||
find_path(RdKafka_INCLUDE_DIR
|
||||
NAMES librdkafka/rdkafka.h
|
||||
HINTS ${RdKafka_ROOT}/include
|
||||
)
|
||||
|
||||
find_library(RdKafka_LIBRARY_PATH
|
||||
NAMES ${RdKafka_LIBNAME} rdkafka
|
||||
HINTS ${RdKafka_ROOT}/lib ${RdKafka_ROOT}/lib64
|
||||
)
|
||||
|
||||
# Check lib paths
|
||||
if (CPPKAFKA_CMAKE_VERBOSE)
|
||||
get_property(FIND_LIBRARY_32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
|
||||
get_property(FIND_LIBRARY_64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||
message(STATUS "RDKAFKA search 32-bit library paths: ${FIND_LIBRARY_32}")
|
||||
message(STATUS "RDKAFKA search 64-bit library paths: ${FIND_LIBRARY_64}")
|
||||
message(STATUS "RdKafka_ROOT = ${RdKafka_ROOT}")
|
||||
message(STATUS "RdKafka_INCLUDE_DIR = ${RdKafka_INCLUDE_DIR}")
|
||||
message(STATUS "RdKafka_LIBNAME = ${RdKafka_LIBNAME}")
|
||||
message(STATUS "RdKafka_LIBRARY_PATH = ${RdKafka_LIBRARY_PATH}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RdKafka DEFAULT_MSG
|
||||
RdKafka_LIBNAME
|
||||
RdKafka_LIBRARY_PATH
|
||||
RdKafka_INCLUDE_DIR
|
||||
)
|
||||
|
||||
set(CONTENTS "#include <librdkafka/rdkafka.h>\n #if RD_KAFKA_VERSION >= ${RDKAFKA_MIN_VERSION_HEX}\n int main() { }\n #endif")
|
||||
set(FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/rdkafka_version_test.cpp)
|
||||
file(WRITE ${FILE_NAME} ${CONTENTS})
|
||||
|
||||
try_compile(RdKafka_FOUND ${CMAKE_CURRENT_BINARY_DIR}
|
||||
SOURCES ${FILE_NAME}
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${RdKafka_INCLUDE_DIR}")
|
||||
|
||||
if (RdKafka_FOUND)
|
||||
add_library(RdKafka::rdkafka ${RDKAFKA_LIBRARY_TYPE} IMPORTED GLOBAL)
|
||||
set(RDKAFKA_DEPENDENCIES pthread)
|
||||
# set(RDKAFKA_DEPENDENCIES pthread rt crypto dl z)
|
||||
set_target_properties(RdKafka::rdkafka PROPERTIES
|
||||
IMPORTED_NAME RdKafka
|
||||
IMPORTED_LOCATION "${RdKafka_LIBRARY_PATH}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${RdKafka_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES "${RDKAFKA_DEPENDENCIES}")
|
||||
message(STATUS "Found valid rdkafka version")
|
||||
mark_as_advanced(
|
||||
RDKAFKA_LIBRARY
|
||||
RdKafka_INCLUDE_DIR
|
||||
RdKafka_LIBRARY_PATH
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Failed to find valid rdkafka version")
|
||||
endif()
|
||||
Reference in New Issue
Block a user