1
1
# Determine the Azmq::libzmq library
2
2
#
3
3
# 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
5
5
#
6
6
# If you need different logic define the "Azmq::libzmq" target
7
7
# before calling add_subdirectory or find azmq
8
8
9
9
if (TARGET Azmq::libzmq)
10
- # 1. allow overriding from the calling script
10
+ # allow overriding from the calling script
11
11
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 )
12
18
else ()
13
- # 2. try finding the package
19
+ # try finding the package
14
20
find_package (ZeroMQ QUIET )
15
21
if (ZeroMQ_FOUND)
16
22
# libzmq exports different targets depending on shared vs static
@@ -31,7 +37,7 @@ else ()
31
37
endif ()
32
38
endif ()
33
39
else ()
34
- # 3. fallback to pkg-config
40
+ # fallback to pkg-config
35
41
message (STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)" )
36
42
find_package (PkgConfig REQUIRED)
37
43
pkg_check_modules(LIBZMQ REQUIRED IMPORTED_TARGET GLOBAL libzmq)
0 commit comments