Fix use of parent oxenc::oxenc target

oxen-mq's export command errored when using a parent oxenc target in a
submodule oxen-mq; add an intermediate IMPORTED target so that cmake
knows it doesn't have to export the oxenc dependency as well.
This commit is contained in:
Jason Rhinelander 2022-05-30 12:33:22 -03:00
parent c4b7aa9b23
commit 4671af3ca0
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
1 changed files with 7 additions and 4 deletions

View File

@ -69,8 +69,11 @@ find_package(Threads REQUIRED)
target_link_libraries(oxenmq PRIVATE Threads::Threads)
if(TARGET oxenc)
target_link_libraries(oxenmq PUBLIC oxenc)
if(TARGET oxenc::oxenc)
add_library(_oxenmq_external_oxenc INTERFACE IMPORTED)
target_link_libraries(_oxenmq_external_oxenc INTERFACE oxenc::oxenc)
target_link_libraries(oxenmq INTERFACE _oxenmq_external_oxenc)
message(STATUS "using pre-existing oxenc::oxenc target")
elseif(BUILD_SHARED_LIBS)
include(FindPkgConfig)
pkg_check_modules(oxenc liboxenc IMPORTED_TARGET)
@ -82,11 +85,11 @@ elseif(BUILD_SHARED_LIBS)
endif()
else()
add_subdirectory(oxen-encoding)
target_link_libraries(oxenmq PUBLIC oxenc)
target_link_libraries(oxenmq PUBLIC oxenc::oxenc)
endif()
else()
add_subdirectory(oxen-encoding)
target_link_libraries(oxenmq PUBLIC oxenc)
target_link_libraries(oxenmq PUBLIC oxenc::oxenc)
endif()
# libzmq is nearly impossible to link statically from a system-installed static library: it depends