2017-07-19 10:43:07 +02:00
|
|
|
cmake_minimum_required(VERSION 3.0.0)
|
2017-01-09 11:39:43 +01:00
|
|
|
|
2018-03-28 12:46:59 +02:00
|
|
|
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
include (DetectCPPZMQVersion)
|
|
|
|
|
|
|
|
project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION})
|
|
|
|
|
2020-03-05 13:59:45 +01:00
|
|
|
if (NOT TARGET libzmq AND NOT TARGET libzmq-static)
|
2020-03-05 10:50:25 +01:00
|
|
|
find_package(ZeroMQ QUIET)
|
2017-07-14 16:03:06 +02:00
|
|
|
|
2020-03-05 10:50:25 +01:00
|
|
|
# libzmq autotools install: fallback to pkg-config
|
|
|
|
if(NOT ZeroMQ_FOUND)
|
2018-05-25 11:13:02 +02:00
|
|
|
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
2018-01-13 23:13:38 +01:00
|
|
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
|
|
|
find_package(ZeroMQ REQUIRED)
|
2020-03-05 10:50:25 +01:00
|
|
|
endif()
|
2017-01-09 11:39:43 +01:00
|
|
|
|
2020-03-05 10:50:25 +01:00
|
|
|
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
|
|
|
if(NOT ZeroMQ_FOUND)
|
2018-05-25 11:13:02 +02:00
|
|
|
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
2020-03-05 10:50:25 +01:00
|
|
|
endif()
|
2018-05-25 11:13:02 +02:00
|
|
|
|
2020-03-17 10:02:44 +01:00
|
|
|
if (ZeroMQ_FOUND AND NOT (TARGET libzmq OR TARGET libzmq-static))
|
2020-03-05 10:50:25 +01:00
|
|
|
message(FATAL_ERROR "ZeroMQ version not supported!")
|
|
|
|
endif()
|
2017-04-04 12:44:52 +02:00
|
|
|
endif()
|
|
|
|
|
2018-05-23 19:34:44 +02:00
|
|
|
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
|
|
|
|
else ()
|
|
|
|
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
|
|
|
|
endif ()
|
2018-04-07 16:08:24 +02:00
|
|
|
if (ENABLE_DRAFTS)
|
2018-04-03 16:30:58 +02:00
|
|
|
ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API)
|
|
|
|
set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1")
|
2018-04-07 16:08:24 +02:00
|
|
|
else (ENABLE_DRAFTS)
|
2018-04-03 16:30:58 +02:00
|
|
|
set (pkg_config_defines "")
|
2018-04-07 16:08:24 +02:00
|
|
|
endif (ENABLE_DRAFTS)
|
2018-04-03 16:30:58 +02:00
|
|
|
|
2018-05-08 15:34:35 +02:00
|
|
|
message(STATUS "cppzmq v${cppzmq_VERSION}")
|
2017-01-09 11:39:43 +01:00
|
|
|
|
|
|
|
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")
|
|
|
|
|
2018-05-18 23:20:45 +02:00
|
|
|
configure_file(libzmq-pkg-config/FindZeroMQ.cmake
|
|
|
|
libzmq-pkg-config/FindZeroMQ.cmake
|
|
|
|
COPYONLY)
|
|
|
|
|
2018-03-28 12:46:59 +02:00
|
|
|
export(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
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})
|
2020-01-15 19:14:26 +01:00
|
|
|
# Workaround until ARCH_INDEPENDENT flag can be used with cmake 3.14.
|
|
|
|
# The ConigVersion.cmake file contains checks for the architecture is was
|
|
|
|
# generated on, which can cause problems for header only libraries
|
|
|
|
# used with e.g. the Conan package manager. Since it is header only we
|
|
|
|
# can/should omit those checks.
|
2020-01-15 11:34:48 +01:00
|
|
|
set(CPPZMQ_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
2020-01-15 19:14:26 +01:00
|
|
|
set(CMAKE_SIZEOF_VOID_P "") # a simple unset is not sufficient
|
2017-01-09 11:39:43 +01:00
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
2018-04-17 20:34:29 +02:00
|
|
|
VERSION ${CPPZMQ_VERSION}
|
2017-01-09 11:39:43 +01:00
|
|
|
COMPATIBILITY AnyNewerVersion)
|
2020-01-15 11:34:48 +01:00
|
|
|
set(CMAKE_SIZEOF_VOID_P ${CPPZMQ_SIZEOF_VOID_P})
|
|
|
|
|
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
|
|
|
|
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
|
2018-01-16 09:13:02 +01:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake
|
2018-01-13 23:13:38 +01:00
|
|
|
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR}/libzmq-pkg-config)
|
2018-04-02 13:21:11 +02:00
|
|
|
|
2018-04-19 12:45:29 +02:00
|
|
|
option(CPPZMQ_BUILD_TESTS "Whether or not to build the tests" ON)
|
|
|
|
|
|
|
|
if (CPPZMQ_BUILD_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(tests)
|
2020-10-10 15:22:26 +02:00
|
|
|
if (CMAKE_CXX_STANDARD AND NOT CMAKE_CXX_STANDARD EQUAL 98 AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2018-04-19 12:45:29 +02:00
|
|
|
endif()
|