Skip to content

Commit

Permalink
CMake: Fix relative paths in generated PackageConfig (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
alerei authored Nov 14, 2024
1 parent 09f8739 commit fd40d05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function(install_zenohc_lib configurations property_postfix package_name)
configure_package_config_file(
"PackageConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${package_name}_${property_postfix}Config.cmake"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR ZENOHC_INSTALL_DYLIBDIR
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}")

# Generate <Package>Version.cmake
Expand Down
18 changes: 5 additions & 13 deletions install/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

set(ZENOHC_BUILD_WITH_UNSTABLE_API @ZENOHC_BUILD_WITH_UNSTABLE_API@)
set(ZENOHC_BUILD_WITH_SHARED_MEMORY @ZENOHC_BUILD_WITH_SHARED_MEMORY@)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()


if(NOT TARGET __zenohc_shared)
Expand All @@ -32,20 +24,20 @@ if(NOT TARGET __zenohc_shared)
set_target_properties(__zenohc_shared PROPERTIES
IMPORTED_NO_SONAME TRUE
INTERFACE_COMPILE_DEFINITION ZENOHC_DYN_LIB
IMPORTED_LOCATION "${_IMPORT_PREFIX}/@ZENOHC_INSTALL_DYLIBDIR@/@DYLIB@"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@"
IMPORTED_LOCATION "@PACKAGE_ZENOHC_INSTALL_DYLIBDIR@/@DYLIB@"
INTERFACE_INCLUDE_DIRECTORIES "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@"
)
if(NOT ("@IMPLIB@" STREQUAL ""))
set_property(TARGET __zenohc_shared PROPERTY IMPORTED_IMPLIB "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@")
set_property(TARGET __zenohc_shared PROPERTY IMPORTED_IMPLIB "@PACKAGE_CMAKE_INSTALL_LIBDIR@/@IMPLIB@")
endif()
endif()
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@"
IMPORTED_LOCATION "@PACKAGE_CMAKE_INSTALL_LIBDIR@/@STATICLIB@"
INTERFACE_INCLUDE_DIRECTORIES "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@"
)
endif()

Expand Down

0 comments on commit fd40d05

Please sign in to comment.