0

I'm using CMake-2.8 on winxp with Visual Studio 2005 generator.

lets say I've a dll created (A.dll) from some cxx files and a static library static.lib

So I call Link_Directories to specify the directory where the static library is located. Now A.dll is built fine.

Now I want B.dll built from some cxx sources, A.lib (the import lib of A.dll)

Now when I say Target_Link_Libraries for (B A), the project file is created with static.lib also as a dependency. Now B has two dependencies A and static.lib. But I'm not adding the directory of static.lib to Link_Directories for B and my build fails.

I do not think B needs to know about static.lib

Any Ideas how to avoid this ?

Thanks in advance, Surya

1 Answer 1

1

From the CMake docs:

Library dependencies are transitive by default. When this target is linked into another target then the libraries linked to this target will appear on the link line for the other target too. See the LINK_INTERFACE_LIBRARIES target property to override the set of transitive link dependencies for a target.

Hence, this should solve your problem:

TARGET_LINK_LIBRARIES(B LINK_INTERFACE_LIBRARIES A)
1
  • May be I did not understand what this LINK_INTERFACE_LIBRARIES does. But when I modified my CMakeLists.txt file with the line above, B project file is created without A itself !!
    – Surya
    Feb 5, 2010 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.