[CMake] Using SET_TARGET_PROPERTIES and IMPORTED_LINK_INTERFACE_LIBRARIES

Craig Scott craig.scott at crascit.com
Wed Dec 13 16:32:48 EST 2017


On Thu, Dec 14, 2017 at 8:22 AM, Saad Khattak <saadrustam at gmail.com> wrote:

> Hi,
>
> I have several imported libraries:
>
> LibA
> LibB
> LibC
>
> Where each imported library has been populated by (where ${LIB_NAME} is
> either LibA, LibB or LibC):
>
> add_library(${LIB_NAME} STATIC IMPORTED)
>
> And each library has the properties IMPORT_LOCATION_${CONFIGURATION} set
> properly:
>
> set_target_properties(${LIB_NAME}
>     PROPERTIES IMPORTED_LOCATION_DEBUG # same for release
>    "location/of/library.lib"
>     )
>
> Now let's say I have another imported library LibD that depends on LibA
> and LibB such that any executable that uses LibD must also link with LibA
> and LibB. To do that, I use:
>
> set_target_properties(LibD
>   PROPERTIES
>     IMPORTED_LINK_INTERFACE_LIBRARIES LibA LibB
>   )
>

You probably want this instead:

set_target_properties(LibD
  PROPERTIES
    IMPORTED_LINK_INTERFACE_LIBRARIES "LibA;LibB"
)


Note that if the property value is a list, you have to provide it as a
single string (i.e. "LibA;LibB" rather than LibA LibB)



-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171214/2878f433/attachment.html>


More information about the CMake mailing list