From 4671af3ca0f85eb5ba194b5093eff13abf218853 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 30 May 2022 12:33:22 -0300 Subject: [PATCH] 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. --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b214872..3a9e8d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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