Skip to content

Commit

Permalink
Merge pull request #98 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 10ced29 + 37bbdcf commit 5d97863
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions install/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@

@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(zenohcxx INTERFACE)
target_include_directories(zenohcxx INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_include_directories(zenohcxx INTERFACE "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")

# zenohcxx for zenohpico
if(TARGET zenohpico)
add_library(zenohcxx_zenohpico INTERFACE)
target_compile_definitions(zenohcxx_zenohpico INTERFACE ZENOHCXX_ZENOHPICO)
target_include_directories(zenohcxx_zenohpico INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_include_directories(zenohcxx_zenohpico INTERFACE "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
add_dependencies(zenohcxx_zenohpico zenohpico)
target_link_libraries(zenohcxx_zenohpico INTERFACE zenohpico)
add_library(zenohcxx::zenohpico ALIAS zenohcxx_zenohpico)
Expand All @@ -32,7 +41,7 @@ if(TARGET zenohc::lib)
message(STATUS "defined lib target zenohcxx::zenohc::lib for zenohc::lib")
add_library(zenohcxx_zenohc_lib INTERFACE)
target_compile_definitions(zenohcxx_zenohc_lib INTERFACE ZENOHCXX_ZENOHC)
target_include_directories(zenohcxx_zenohc_lib INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_include_directories(zenohcxx_zenohc_lib INTERFACE "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
add_dependencies(zenohcxx_zenohc_lib zenohc::lib)
target_link_libraries(zenohcxx_zenohc_lib INTERFACE zenohc::lib)
add_library(zenohcxx::zenohc::lib ALIAS zenohcxx_zenohc_lib)
Expand All @@ -43,7 +52,7 @@ if(TARGET zenohc::shared)
message(STATUS "defined lib target if(TARGET zenohc::shared for zenohc::shared")
add_library(zenohcxx_zenohc_shared INTERFACE)
target_compile_definitions(zenohcxx_zenohc_shared INTERFACE ZENOHCXX_ZENOHC)
target_include_directories(zenohcxx_zenohc_shared INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_include_directories(zenohcxx_zenohc_shared INTERFACE "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
add_dependencies(zenohcxx_zenohc_shared zenohc::shared)
target_link_libraries(zenohcxx_zenohc_shared INTERFACE zenohc::shared)
add_library(zenohcxx::zenohc::shared ALIAS zenohcxx_zenohc_shared)
Expand All @@ -54,7 +63,7 @@ if(TARGET zenohc::static)
message(STATUS "defined lib target zenohcxx::zenohc::static for zenohc::static")
add_library(zenohcxx_zenohc_static INTERFACE)
target_compile_definitions(zenohcxx_zenohc_static INTERFACE ZENOHCXX_ZENOHC)
target_include_directories(zenohcxx_zenohc_static INTERFACE "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
target_include_directories(zenohcxx_zenohc_static INTERFACE "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
add_dependencies(zenohcxx_zenohc_static zenohc::static)
target_link_libraries(zenohcxx_zenohc_static INTERFACE zenohc::static)
add_library(zenohcxx::zenohc::static ALIAS zenohcxx_zenohc_static)
Expand Down

0 comments on commit 5d97863

Please sign in to comment.