diff --git a/install/PackageConfig.cmake.in b/install/PackageConfig.cmake.in index e803d012f..b832e1ed7 100644 --- a/install/PackageConfig.cmake.in +++ b/install/PackageConfig.cmake.in @@ -25,32 +25,35 @@ if(_IMPORT_PREFIX STREQUAL "/") set(_IMPORT_PREFIX "") endif() -add_library(__zenohc_static STATIC IMPORTED GLOBAL) -message(STATUS "ZENOHC_BUILD_WITH_UNSTABLE_API=${ZENOHC_BUILD_WITH_UNSTABLE_API}") -message(STATUS "ZENOHC_BUILD_WITH_SHARED_MEMORY=${ZENOHC_BUILD_WITH_SHARED_MEMORY}") - -add_library(zenohc::static ALIAS __zenohc_static) -target_link_libraries(__zenohc_static INTERFACE @NATIVE_STATIC_LIBS@) -set_target_properties(__zenohc_static PROPERTIES - IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@STATICLIB@" - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@" -) +if(NOT TARGET __zenohc_static) + add_library(__zenohc_static STATIC IMPORTED GLOBAL) + add_library(zenohc::static ALIAS __zenohc_static) + target_link_libraries(__zenohc_static INTERFACE @NATIVE_STATIC_LIBS@) + set_target_properties(__zenohc_static PROPERTIES + IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@STATICLIB@" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@" + ) +endif() -add_library(__zenohc_shared SHARED IMPORTED GLOBAL) -add_library(zenohc::shared ALIAS __zenohc_shared) -set_target_properties(__zenohc_shared PROPERTIES - IMPORTED_NO_SONAME TRUE - INTERFACE_COMPILE_DEFINITION ZENOHC_DYN_LIB - IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@DYLIB@" - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@" -) +if(NOT TARGET __zenohc_shared) + add_library(__zenohc_shared SHARED IMPORTED GLOBAL) + add_library(zenohc::shared ALIAS __zenohc_shared) + set_target_properties(__zenohc_shared PROPERTIES + IMPORTED_NO_SONAME TRUE + INTERFACE_COMPILE_DEFINITION ZENOHC_DYN_LIB + IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@DYLIB@" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@" + ) +endif() if(NOT ("@IMPLIB@" STREQUAL "")) set_property(TARGET __zenohc_shared PROPERTY IMPORTED_IMPLIB "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@") endif() -if(ZENOHC_LIB_STATIC) +if(NOT TARGET zenohc::lib) + if(ZENOHC_LIB_STATIC) add_library(zenohc::lib ALIAS __zenohc_static) -else() + else() add_library(zenohc::lib ALIAS __zenohc_shared) + endif() endif()