From f58a276f43fa781aa7c27b7cf7fa39b07a34d14a Mon Sep 17 00:00:00 2001 From: ialexyi Date: Thu, 12 Feb 2026 13:17:27 +0000 Subject: [PATCH] Export stable Azmq::libzmq target Create INTERFACE IMPORTED target instead of aliasing PkgConfig::LIBZMQ to avoid exporting pkg-config targets in azmq's exported configuration. When azmq creates an ALIAS to PkgConfig::LIBZMQ, the pkg-config target gets included in azmq's exported CMake config, causing downstream builds to fail when pkg-config results differ between environments. This patch copies the properties from PkgConfig::LIBZMQ into a new INTERFACE IMPORTED target to break the dependency on pkg-config in the exported configuration. The implementation includes null checks for robustness and copies all relevant INTERFACE_* properties including link libraries, include directories, compile options, compile definitions, and link options. --- FindAzmqLibzmq.cmake | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/FindAzmqLibzmq.cmake b/FindAzmqLibzmq.cmake index cad6b5b2..1bc50f17 100644 --- a/FindAzmqLibzmq.cmake +++ b/FindAzmqLibzmq.cmake @@ -42,9 +42,26 @@ else () find_package(PkgConfig REQUIRED) pkg_check_modules(LIBZMQ REQUIRED IMPORTED_TARGET GLOBAL libzmq) if (LIBZMQ_FOUND) - add_library(Azmq::libzmq ALIAS PkgConfig::LIBZMQ) + # Create INTERFACE IMPORTED target to avoid exporting PkgConfig::LIBZMQ + add_library(Azmq::libzmq INTERFACE IMPORTED GLOBAL) + + # Copy all relevant properties from pkg-config target + foreach(_prop IN ITEMS + INTERFACE_LINK_LIBRARIES + INTERFACE_INCLUDE_DIRECTORIES + INTERFACE_COMPILE_OPTIONS + INTERFACE_COMPILE_DEFINITIONS + INTERFACE_LINK_OPTIONS + ) + get_target_property(_value PkgConfig::LIBZMQ ${_prop}) + if(_value AND NOT _value MATCHES "-NOTFOUND$") + set_property(TARGET Azmq::libzmq PROPERTY ${_prop} "${_value}") + endif() + endforeach() + unset(_value) + unset(_prop) else () message(FAIL_ERROR "Can't find the required libzmq library") endif () endif () -endif () \ No newline at end of file +endif ()