Rework IMPORTED framework support
I've discovered/talked about this with @brad.king while working on #21752 (closed).
As it stands right now, there are some inconsistencies in how IMPORTED
.framework
libraries are supported:
-
target_link_libraries(foo PRIVATE /usr/lib/bar.framework)
links using-F/usr/lib -framework bar
. We could instead simply pass/usr/lib/bar.framework/bar
to the linker. -
IMPORTED
libraries that point to a.framework
have to have the full library path in theirIMPORTED_LOCATION
. This results in code like the following:if(BAR_LIBRARY MATCHES "/([^/]+)\\.framework$") set_property(TARGET bar::bar PROPERTY IMPORTED_LOCATION "${BAR_LIBRARY}/${CMAKE_MATCH_1}") set_property(TARGET bar::bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BAR_LIBRARY}") endif()
We should either allow
IMPORTED
targets to have the.framework
directly as itsIMPORTED_LOCATION
and do the right thing automatically with respect to the library and the include directory, or create a module with a function that shorthands this pattern.
The above changes may require a policy. I'll add more bullet points as I discover them.