mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-10-29 17:52:26 +00:00
Added options to conditionally disable installation of configuration files
This commit is contained in:
@@ -44,6 +44,8 @@ option(CPPKAFKA_DISABLE_EXAMPLES "Disable build of cppkafka examples." OFF)
|
||||
option(CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON)
|
||||
option(CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON)
|
||||
option(CPPKAFKA_RDKAFKA_STATIC_LIB "Link with Rdkafka static library." OFF)
|
||||
option(CPPKAFKA_EXPORT_PKGCONFIG "Generate 'cppkafka.pc' file" ON)
|
||||
option(CPPKAFKA_EXPORT_CMAKE_CONFIG "Generate CMake config, target and version files." ON)
|
||||
|
||||
# Add FindRdKafka.cmake
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||
|
||||
@@ -83,6 +83,8 @@ The following cmake options can be specified:
|
||||
* `CPPKAFKA_RDKAFKA_STATIC_LIB` : Link to Rdkafka static library. Default is `OFF`.
|
||||
* `CPPKAFKA_CONFIG_DIR` : Install location of the cmake configuration files. Default is `lib/cmake/cppkafka`.
|
||||
* `CPPKAFKA_PKGCONFIG_DIR` : Install location of the .pc file. Default is `share/pkgconfig`.
|
||||
* `CPPKAFKA_EXPORT_PKGCONFIG` : Generate `cppkafka.pc` file. Default is `ON`.
|
||||
* `CPPKAFKA_EXPORT_CMAKE_CONFIG` : Generate CMake config, target and version files. Default is `ON`.
|
||||
|
||||
Example:
|
||||
```Shell
|
||||
|
||||
@@ -11,7 +11,7 @@ set(RDKAFKA_MIN_VERSION_HEX "@RDKAFKA_MIN_VERSION_HEX@")
|
||||
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.
|
||||
# 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)
|
||||
|
||||
@@ -64,40 +64,44 @@ install(
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
# Install the exported file
|
||||
install(
|
||||
EXPORT "${TARGET_EXPORT_NAME}"
|
||||
NAMESPACE "${NAMESPACE}"
|
||||
COMPONENT config
|
||||
DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
)
|
||||
if (CPPKAFKA_EXPORT_PKGCONFIG)
|
||||
# Generate and install pkgconfig file
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/cppkafka.pc.in ${PKG_CONFIG_FILE} @ONLY)
|
||||
|
||||
# Generate and install pkgconfig file
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/cppkafka.pc.in ${PKG_CONFIG_FILE} @ONLY)
|
||||
install(
|
||||
FILES ${PKG_CONFIG}
|
||||
DESTINATION "${CPPKAFKA_PKGCONFIG_DIR}"
|
||||
COMPONENT pkgconfig
|
||||
)
|
||||
endif()
|
||||
|
||||
install(
|
||||
FILES ${PKG_CONFIG}
|
||||
DESTINATION "${CPPKAFKA_PKGCONFIG_DIR}"
|
||||
COMPONENT pkgconfig
|
||||
)
|
||||
if (CPPKAFKA_EXPORT_CMAKE_CONFIG)
|
||||
# Install the exported file
|
||||
install(
|
||||
EXPORT "${TARGET_EXPORT_NAME}"
|
||||
NAMESPACE "${NAMESPACE}"
|
||||
COMPONENT config
|
||||
DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
)
|
||||
|
||||
# Generate CMAKE configuration file and exported targets
|
||||
configure_package_config_file(
|
||||
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in"
|
||||
"${CONFIG_FILE}"
|
||||
INSTALL_DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
PATH_VARS RDKAFKA_MIN_VERSION_HEX CMAKE_INSTALL_PREFIX CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
|
||||
)
|
||||
# Generate CMAKE configuration file and exported targets
|
||||
configure_package_config_file(
|
||||
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in"
|
||||
"${CONFIG_FILE}"
|
||||
INSTALL_DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
PATH_VARS RDKAFKA_MIN_VERSION_HEX CMAKE_INSTALL_PREFIX CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
|
||||
)
|
||||
|
||||
# Generate version file
|
||||
write_basic_package_version_file(
|
||||
"${VERSION_FILE}"
|
||||
VERSION ${CPPKAFKA_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
# Generate version file
|
||||
write_basic_package_version_file(
|
||||
"${VERSION_FILE}"
|
||||
VERSION ${CPPKAFKA_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${CONFIG_FILE}" "${VERSION_FILE}" "${FIND_RDKAFKA_FILE}"
|
||||
DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
COMPONENT config
|
||||
)
|
||||
install(
|
||||
FILES "${CONFIG_FILE}" "${VERSION_FILE}" "${FIND_RDKAFKA_FILE}"
|
||||
DESTINATION "${CPPKAFKA_CONFIG_DIR}"
|
||||
COMPONENT config
|
||||
)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user