Skip to content

Commit

Permalink
Merge pull request #241 from filippobrizzi/fix_cmake_install
Browse files Browse the repository at this point in the history
Fix: cmake install shouldn't hardcode install path
  • Loading branch information
milyin authored Feb 14, 2024
2 parents d1ec83d + df4682b commit 5bffd9e
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions install/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,38 @@

@PACKAGE_INIT@

# 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()

add_library(__zenohc_static STATIC IMPORTED GLOBAL)
add_library(zenohc::static ALIAS __zenohc_static)
set_property(TARGET __zenohc_static PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@STATICLIB@")
target_link_libraries(__zenohc_static INTERFACE @NATIVE_STATIC_LIBS@)
target_include_directories(__zenohc_static INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
set_target_properties(__zenohc_static PROPERTIES
IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@STATICLIB@"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@"
)

add_library(__zenohc_shared SHARED IMPORTED GLOBAL)
add_library(zenohc::shared ALIAS __zenohc_shared)
set_target_properties(__zenohc_shared PROPERTIES IMPORTED_NO_SONAME TRUE)
set_property(TARGET __zenohc_shared PROPERTY IMPORTED_LOCATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@DYLIB@")
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 ("@IMPLIB@" STREQUAL ""))
set_property(TARGET __zenohc_shared PROPERTY IMPORTED_IMPLIB "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@")
set_property(TARGET __zenohc_shared PROPERTY IMPORTED_IMPLIB "${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@/@IMPLIB@")
endif()
target_include_directories(__zenohc_shared INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_compile_definitions(__zenohc_shared INTERFACE ZENOHC_DYN_LIB)

if(ZENOHC_LIB_STATIC)
add_library(zenohc::lib ALIAS __zenohc_static)
else()
add_library(zenohc::lib ALIAS __zenohc_shared)
endif()
endif()

0 comments on commit 5bffd9e

Please sign in to comment.