[cmake-developers] Setting the link interface and dependencies in one command
Brad King
brad.king at kitware.com
Thu Oct 6 16:35:04 EDT 2011
On 10/5/2011 9:47 AM, Stephen Kelly wrote:
> Thanks for all of your explanations. It seems that introducing a way to do
> this with one command has some support.
>
> So if SOME_FEATURE is true,
>
> target_link_libraries(foo bar SOME_KEYWORD baz)
> if (SOME_FEATURE)
> target_link_libraries(foo mar SOME_KEYWORD maz)
> endif()
>
> would have to result in bar and mar not being part of the link interface,
> and baz and maz being part of the link interface.
>
> How do we decide on a keyword there? LINK_INTERFACE_DEPENDENCIES perhaps?
One possible problem with making it a keyword is that the name could appear
in a list of libraries and invisibly transform a target_link_libraries call.
What we need is a pair of keywords to switch between link+interface and
link-only dependencies. We allow the keywords only if one of the two is
the second argument to the command after the target name. For example,
they can be called "LINK_INTERFACE" for link+interface and "LINK_DEPENDS"
for link-only:
target_link_libraries(foo LINK_INTERFACE bar LINK_DEPENDS baz)
if(SOME_FEATURE)
target_link_libraries(foo LINK_INTERFACE mar LINK_DEPENDS maz)
endif()
Other possible names? Perhaps LINK_PUBLIC and LINK_PRIVATE?
Perhaps LINK AND LINK_ONLY?
-Brad
More information about the cmake-developers
mailing list