Skip to content

Commit 392a2ee

Browse files
aboseleyAdam Boseley
authored and
Adam Boseley
committed
cmake: use existing libzmq targets if they exist
1 parent 49ffa6f commit 392a2ee

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

FindAzmqLibzmq.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Determine the Azmq::libzmq library
22
#
33
# This script is a wrapper around find_package and pkg-config
4-
# so inclusion of azmq just works for both install types of libzmq
4+
# so inclusion of azmq just works for both install types
55
#
66
# If you need different logic define the "Azmq::libzmq" target
77
# before calling add_subdirectory or find azmq
88

99
if (TARGET Azmq::libzmq)
10-
# 1. allow overriding from the calling script
10+
# allow overriding from the calling script
1111
message(STATUS "using provided Azmq::libzmq target")
12+
elseif (TARGET libzmq AND BUILD_SHARED_LIBS)
13+
message(STATUS "using existing shared library target")
14+
add_library(Azmq::libzmq ALIAS libzmq)
15+
elseif (TARGET libzmq-static AND NOT BUILD_SHARED_LIBS)
16+
message(STATUS "using existing static library target")
17+
add_library(Azmq::libzmq ALIAS libzmq-static)
1218
else ()
13-
# 2. try finding the package
19+
# try finding the package
1420
find_package(ZeroMQ QUIET)
1521
if (ZeroMQ_FOUND)
1622
# libzmq exports different targets depending on shared vs static
@@ -31,7 +37,7 @@ else ()
3137
endif ()
3238
endif ()
3339
else ()
34-
# 3. fallback to pkg-config
40+
# fallback to pkg-config
3541
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
3642
find_package(PkgConfig REQUIRED)
3743
pkg_check_modules(LIBZMQ REQUIRED IMPORTED_TARGET GLOBAL libzmq)

0 commit comments

Comments
 (0)