mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
cmake: Export targets to package config
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
This commit is contained in:
parent
4e3e3f659d
commit
f186421273
@ -777,6 +777,15 @@ else ()
|
|||||||
PREFIX "")
|
PREFIX "")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
foreach (target libzmq libzmq-static)
|
||||||
|
target_include_directories (${target}
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
target_link_libraries (libzmq ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (libzmq ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
if (SODIUM_FOUND)
|
if (SODIUM_FOUND)
|
||||||
@ -856,6 +865,7 @@ include(GNUInstallDirs)
|
|||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
install (TARGETS libzmq libzmq-static
|
install (TARGETS libzmq libzmq-static
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
@ -878,6 +888,7 @@ if (MSVC)
|
|||||||
endif ()
|
endif ()
|
||||||
else ()
|
else ()
|
||||||
install (TARGETS libzmq libzmq-static
|
install (TARGETS libzmq libzmq-static
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
@ -911,26 +922,22 @@ endif ()
|
|||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
|
|
||||||
get_property(libzmq_pf TARGET libzmq PROPERTY ${U_CMAKE_BUILD_TYPE}_POSTFIX)
|
|
||||||
set(libzmq_file libzmq${libzmq_pf}${CMAKE_LINK_LIBRARY_SUFFIX})
|
|
||||||
get_property(libzmq_static_pf TARGET libzmq-static PROPERTY ${U_CMAKE_BUILD_TYPE}_POSTFIX)
|
|
||||||
set(libzmq_static_file libzmq${libzmq_static_pf}${CMAKE_LINK_LIBRARY_SUFFIX})
|
|
||||||
else()
|
|
||||||
set(libzmq_file libzmq${CMAKE_SHARED_LIBRARY_SUFFIX})
|
|
||||||
set(libzmq_static_file libzmq${CMAKE_STATIC_LIBRARY_SUFFIX})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
|
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
|
||||||
set(ZEROMQ_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for ZeroMQConfig.cmake")
|
set(ZEROMQ_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for ZeroMQConfig.cmake")
|
||||||
|
|
||||||
|
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
export(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||||
|
endif()
|
||||||
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
|
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
INSTALL_DESTINATION ${ZEROMQ_CMAKECONFIG_INSTALL_DIR})
|
INSTALL_DESTINATION ${ZEROMQ_CMAKECONFIG_INSTALL_DIR})
|
||||||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||||
VERSION ${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}
|
VERSION ${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}
|
||||||
COMPATIBILITY AnyNewerVersion)
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
install(EXPORT ${PROJECT_NAME}-targets
|
||||||
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
|
DESTINATION ${ZEROMQ_CMAKECONFIG_INSTALL_DIR})
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||||
DESTINATION ${ZEROMQ_CMAKECONFIG_INSTALL_DIR})
|
DESTINATION ${ZEROMQ_CMAKECONFIG_INSTALL_DIR})
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
# ZeroMQ cmake module
|
# ZeroMQ cmake module
|
||||||
|
#
|
||||||
|
# The following import targets are created
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# libzmq-static
|
||||||
|
# libzmq
|
||||||
|
#
|
||||||
# This module sets the following variables in your project::
|
# This module sets the following variables in your project::
|
||||||
#
|
#
|
||||||
# ZeroMQ_FOUND - true if ZeroMQ found on the system
|
# ZeroMQ_FOUND - true if ZeroMQ found on the system
|
||||||
@ -8,8 +16,10 @@
|
|||||||
|
|
||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
set(PN ZeroMQ)
|
if(NOT TARGET libzmq AND NOT TARGET libzmq-static)
|
||||||
set_and_check(${PN}_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||||
set_and_check(${PN}_LIBRARY "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@/@libzmq_file@")
|
endif()
|
||||||
set_and_check(${PN}_STATIC_LIBRARY "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@/@libzmq_static_file@")
|
|
||||||
check_required_components(${PN})
|
get_target_property(@PROJECT_NAME@_INCLUDE_DIR libzmq INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
get_target_property(@PROJECT_NAME@_LIBRARY libzmq LOCATION)
|
||||||
|
get_target_property(@PROJECT_NAME@_STATIC_LIBRARY libzmq-static LOCATION)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user