Merge pull request #389 from SylvainCorlay/wrap-find-package-zeromq

Wraping calls to find_package
This commit is contained in:
Simon Giesecke 2020-03-07 15:04:22 +01:00 committed by GitHub
commit c7766c083a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,22 +6,24 @@ include (DetectCPPZMQVersion)
project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION}) project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION})
find_package(ZeroMQ QUIET) if (NOT TARGET libzmq AND NOT TARGET libzmq-static)
find_package(ZeroMQ QUIET)
# libzmq autotools install: fallback to pkg-config # libzmq autotools install: fallback to pkg-config
if(NOT ZeroMQ_FOUND) if(NOT ZeroMQ_FOUND)
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)") message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
find_package(ZeroMQ REQUIRED) find_package(ZeroMQ REQUIRED)
endif() endif()
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work # TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
if(NOT ZeroMQ_FOUND) if(NOT ZeroMQ_FOUND)
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config") message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
endif() endif()
if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static)) if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static))
message(FATAL_ERROR "ZeroMQ version not supported!") message(FATAL_ERROR "ZeroMQ version not supported!")
endif()
endif() endif()
if (EXISTS "${CMAKE_SOURCE_DIR}/.git") if (EXISTS "${CMAKE_SOURCE_DIR}/.git")