[CMake] How to deal with incompatible changes in interface of target_link_libraries()?

Brad King brad.king at kitware.com
Tue Aug 12 09:06:16 EDT 2014


On 08/12/2014 03:48 AM, Marcel Loose wrote:
> That's probably in the CMake 3.0.x docs; CMake 2.8.12 doesn't mention
> LINK_PUBLIC and LINK_PRIVATE in the policy documentation. I only read
> the following in the docs on target_link_libraries
> 
>        The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify
> both the
>        link dependencies and the link interface in one command.  This
>        signature is for compatibility only.  Prefer the PUBLIC or PRIVATE
>        keywords instead. 
> 
> "... for compatibility only" didn't give me the feeling that this is the
> way to go, which is underscored by the next sentence: "Prefer the ..."

If your project requires CMake 2.8.12 or higher then it is preferred to
use PUBLIC/PRIVATE.  For compatibility with earlier CMake versions you
can still use LINK_PUBLIC/LINK_PRIVATE.

> On a side note. Even using the new PRIVATE and PUBLIC keywords I am
> unable to exactly specify which libraries are needed for linking.

Can you provide a concrete example of this trouble?

-Brad



More information about the CMake mailing list