Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent reading non-whitelisted properties of interface targets. #916

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmake/catkin_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,15 @@ function(catkin_replace_imported_library_targets VAR)
# sometimes cmake dependencies define imported targets, in which
# case the imported library information is not the target name, but
# the information embedded in cmake properties inside the imported library
# For interface libraries, this is the INTERFACE_LINK_LIBRARIES property.
# For regular imported libraries, this is IMPORTED_LOCATION(_$CONFIG).
get_target_property(${lib}_type ${lib} TYPE)
get_target_property(${lib}_imported ${lib} IMPORTED)
if(${${lib}_imported})
if(${${lib}_type} STREQUAL "INTERFACE_LIBRARY")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any documentation about the "string" INTERFACE_LIBRARY.

Maybe get_property(... SET/DEFINED) could be used instead if this can't be relied on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is here: https://cmake.org/cmake/help/v3.1/prop_tgt/TYPE.html

It first appeared in cmake 3.1, but since older cmakes will never report "INTERFACE_LIBRARY", it is automatically backwards compatible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the reference. I was indeed looking at the 3.0 docs.

get_target_property(${lib}_interface_link_libraries ${lib} INTERFACE_LINK_LIBRARIES)
catkin_replace_imported_library_targets(${lib}_resolved_libs ${${lib}_interface_link_libraries})
list(APPEND result ${${lib}_resolved_libs})
elseif(${${lib}_imported})
set(imported_libraries) # empty list
get_target_property(${lib}_imported_location ${lib} IMPORTED_LOCATION)
if(${lib}_imported_location)
Expand Down