From 8d731ea900e0d5c9ba51859ca1cf3881fb488e5d Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 5 Mar 2020 10:50:25 +0100 Subject: [PATCH 1/2] Wrap find_package --- CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81e19e8..793060d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,22 +6,24 @@ include (DetectCPPZMQVersion) project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION}) -find_package(ZeroMQ QUIET) +if (NOT TARGET libzmq) + find_package(ZeroMQ QUIET) -# libzmq autotools install: fallback to pkg-config -if(NOT ZeroMQ_FOUND) + # libzmq autotools install: fallback to pkg-config + if(NOT ZeroMQ_FOUND) 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) 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 -if(NOT ZeroMQ_FOUND) + # TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work + if(NOT ZeroMQ_FOUND) 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)) - message(FATAL_ERROR "ZeroMQ version not supported!") + if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static)) + message(FATAL_ERROR "ZeroMQ version not supported!") + endif() endif() if (EXISTS "${CMAKE_SOURCE_DIR}/.git") From 9cb042e711e21119b21f663706e4f81d83eaf6ac Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 5 Mar 2020 13:59:45 +0100 Subject: [PATCH 2/2] Also skip if libzmq-static is defined --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 793060d..0c21fc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ include (DetectCPPZMQVersion) project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION}) -if (NOT TARGET libzmq) +if (NOT TARGET libzmq AND NOT TARGET libzmq-static) find_package(ZeroMQ QUIET) # libzmq autotools install: fallback to pkg-config