diff --git a/CMakeLists.txt b/CMakeLists.txt index d564bd435..4a630300b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,6 +322,11 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico DESTINATION include COMPONENT Headers ) +if(BUILD_SHARED_LIBS) + set(LIBNAME ${CMAKE_SHARED_LIBRARY_PREFIX}${Libname}${CMAKE_SHARED_LIBRARY_SUFFIX}) +else() + set(LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}${Libname}${CMAKE_STATIC_LIBRARY_SUFFIX}) +endif() set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/zenohpico") # Generate Config.cmake diff --git a/PackageConfig.cmake.in b/PackageConfig.cmake.in index 800ceff6c..6c733dc69 100644 --- a/PackageConfig.cmake.in +++ b/PackageConfig.cmake.in @@ -14,18 +14,28 @@ @PACKAGE_INIT@ -add_library(__zenohpico_static STATIC IMPORTED GLOBAL) -add_library(zenohpico::static ALIAS __zenohpico_static) -set_property(TARGET __zenohpico_static PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@STATICLIB@") +set(ZENOHPICO_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) +set(CMAKE_SYSTEM_NAME @CMAKE_SYSTEM_NAME@) -add_library(__zenohpico_lib SHARED IMPORTED GLOBAL) -add_library(zenohpico::lib ALIAS __zenohpico_lib) -set_target_properties(__zenohpico_lib PROPERTIES IMPORTED_NO_SONAME TRUE) -set_property(TARGET __zenohpico_lib PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@DYLIB@") -if(NOT ("@IMPLIB@" STREQUAL "")) - set_property(TARGET __zenohpico_lib PROPERTY IMPORTED_IMPLIB "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@") +if(ZENOHPICO_BUILD_SHARED_LIBS) + if (NOT TARGET __zenohpico_lib) + add_library(__zenohpico_lib SHARED IMPORTED GLOBAL) + add_library(zenohpico::lib ALIAS __zenohpico_lib) + set_target_properties(__zenohpico_lib PROPERTIES IMPORTED_NO_SONAME TRUE) + set_property(TARGET __zenohpico_lib PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@LIBNAME@") + if(NOT ("@IMPLIB@" STREQUAL "")) + set_property(TARGET __zenohpico_lib PROPERTY IMPORTED_IMPLIB "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@") + endif() + target_include_directories(__zenohpico_lib INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") + endif() +else() + if (NOT TARGET __zenohpico_static) + add_library(__zenohpico_static STATIC IMPORTED GLOBAL) + add_library(zenohpico::lib ALIAS __zenohpico_static) + set_property(TARGET __zenohpico_static PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@LIBNAME@") + target_include_directories(__zenohpico_static INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") + endif() endif() -target_include_directories(__zenohpico_lib INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") if(CMAKE_SYSTEM_NAME MATCHES "Linux") add_compile_definitions(ZENOH_LINUX) diff --git a/zenohpico.pc b/zenohpico.pc index 99c36210a..29f1b19aa 100644 --- a/zenohpico.pc +++ b/zenohpico.pc @@ -3,6 +3,6 @@ prefix=/usr/local Name: zenohpico Description: URL: -Version: 1.0.20240715dev +Version: 1.0.20240719dev Cflags: -I${prefix}/include Libs: -L${prefix}/lib -lzenohpico