ros / console_bridge

A ROS-independent package for logging that seamlessly pipes into rosconsole/rosout for ROS-dependent packages.
BSD 3-Clause "New" or "Revised" License
22 stars 62 forks source link

Target is not correctly being exported, missing INTERFACE_INCLUDE_DIRECTORIES. #91

Open Levi-Armstrong opened 3 years ago

Levi-Armstrong commented 3 years ago

I ran into an issue where my project could not find the header console_bridge/console_bridge.h event though find_package was able to find the package. After further investigation I found that the target console_bridge::console_bridge provided by does not set the targets INTERFACE_INCLUDE_DIRECTORIES, but it does set the cmake variable console_bridge_INCLUDE_DIRS.

Reproduce:

find_package(console_bridge REQUIRED)
get_target_property(GET_INCLUDES console_bridge::console_bridge INTERFACE_INCLUDE_DIRECTORIES)
message(AUTHOR_WARNING "console_bridge Interface Includes: ${GET_INCLUDES}")

add_library(${PROJECT_NAME} src/osqp_eigen_solver.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC console_bridge::console_bridge)

Output:

console_bridge Interface Includes: GET_INCLUDES-NOTFOUND
Levi-Armstrong commented 3 years ago

To solve the issue temperately I had to add the following below to all cmake file performing a find_package.

get_target_property(CHECK_INCLUDE_DIRECTORIES console_bridge::console_bridge INTERFACE_INCLUDE_DIRECTORIES)
if (NOT ${CHECK_INCLUDE_DIRECTORIES})
  set_target_properties(console_bridge::console_bridge PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${console_bridge_INCLUDE_DIRS})
endif()