2017-07-19 10:43:07 +02:00
|
|
|
cmake_minimum_required(VERSION 3.0.0)
|
2017-01-09 11:39:43 +01:00
|
|
|
project(cppzmq)
|
|
|
|
|
2017-07-14 16:03:06 +02:00
|
|
|
find_package(ZeroMQ)
|
|
|
|
|
|
|
|
# libzmq autotools install: fallback to pkg-config
|
|
|
|
if(NOT ZeroMQ_FOUND)
|
2017-07-18 20:15:41 +02:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/libzmqPkgConfigFallback.cmake)
|
2017-07-14 16:03:06 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ZeroMQ_FOUND)
|
|
|
|
message(FATAL_ERROR "ZeroMQ was NOT found!")
|
|
|
|
endif()
|
2017-01-09 11:39:43 +01:00
|
|
|
|
2017-04-04 12:44:52 +02:00
|
|
|
if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static))
|
|
|
|
message(FATAL_ERROR "ZeroMQ version not supported!")
|
|
|
|
endif()
|
|
|
|
|
2017-01-10 18:10:09 +01:00
|
|
|
set (${PROJECT_NAME}_VERSION ${ZeroMQ_VERSION})
|
2017-01-09 11:39:43 +01:00
|
|
|
message(STATUS "cppzmq v${${PROJECT_NAME}_VERSION}")
|
|
|
|
|
|
|
|
set(CPPZMQ_HEADERS
|
|
|
|
zmq.hpp
|
|
|
|
zmq_addon.hpp
|
|
|
|
)
|
|
|
|
|
2017-04-04 12:44:52 +02:00
|
|
|
foreach (target cppzmq cppzmq-static)
|
|
|
|
add_library(${target} INTERFACE)
|
|
|
|
target_include_directories(${target} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:include>)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
target_link_libraries(cppzmq INTERFACE libzmq)
|
|
|
|
target_link_libraries(cppzmq-static INTERFACE libzmq-static)
|
|
|
|
|
2017-01-09 11:39:43 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2017-04-04 12:44:52 +02:00
|
|
|
install(TARGETS cppzmq cppzmq-static
|
|
|
|
EXPORT ${PROJECT_NAME}-targets)
|
|
|
|
|
2017-01-09 11:39:43 +01:00
|
|
|
install(FILES ${CPPZMQ_HEADERS}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
|
|
|
|
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
|
|
|
|
set(CPPZMQ_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for cppzmqConfig.cmake")
|
|
|
|
|
2017-04-04 12:44:52 +02:00
|
|
|
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
|
|
|
|
export(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
|
|
|
endif()
|
2017-01-09 11:39:43 +01:00
|
|
|
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
|
|
INSTALL_DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
|
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
|
|
|
VERSION ${${PROJECT_NAME}_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
2017-04-04 12:44:52 +02:00
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}Targets.cmake
|
|
|
|
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
|
2017-01-09 11:39:43 +01:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
2017-07-18 20:15:41 +02:00
|
|
|
${CMAKE_SOURCE_DIR}/libzmqPkgConfigFallback.cmake
|
2017-01-09 11:39:43 +01:00
|
|
|
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
|