Hi,
I’m working on a shared dll library project called resource_retriever
, it has exported cmake like this:
set_target_properties(resource_retriever::resource_retriever PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/resource_retriever"
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ament_index_cpp::ament_index_cpp>;\$<LINK_ONLY:CURL::libcurl>"
)
please note the LINK_ONLY
inside, and it is from the source cmake code:
target_link_libraries(${PROJECT_NAME} PRIVATE
ament_index_cpp::ament_index_cpp
CURL::libcurl
)
Please note the PRIVATE
usage.
Then in project of rviz_rendering
, it uses resource_retriever
like this:
find_package(ament_index_cpp REQUIRED)
...
find_package(resource_retriever REQUIRED)
please note that there is no find_package
for CURL
.
Then when I compile rviz_rendering
, I have this error:
— stderr: rviz_rendering
CMake Error at C:/ros/jazzy/install/share/resource_retriever/cmake/resource_retrieverExport.cmake:61 (set_target_properties):
The link interface of target “resource_retriever::resource_retriever”
contains:
CURL::libcurl
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Please note that the error message is only for CURL
but not ament_index_cpp
. I guess it’s because find_package(ament_index_cpp
is already used.
So here comes the question:
it seems that I need to use find_package
for INTERFACE_LINK_LIBRARIES LINK_ONLY
? Here in my case, for both CURL
and ament_index_cpp
. If it’s correct, then what is LINK_ONLY
for?