[CMake] newbie - VC++ external link dependency
Philip Lowman
philip at yhbt.com
Tue Jul 15 07:07:38 EDT 2008
On Tue, Jul 15, 2008 at 4:53 AM, Jack Andrews <effbiae at gmail.com> wrote:
> hi guys,
>
> i've got a small library (portlib) that does things including sockets
> on linux and windows. my problem is that many executables depend on
> this library and it seems that for every executable i also have to add
>
> IF(WIN32)
> LINK_LIBRARIES(wsock32 ws2_32 portlib)
> ENDIF(WIN32)
>
> that is, on top of portlib, i have to specify windows libs. i can't
> seem to work out how i can get away with just:
>
> LINK_LIBRARIES(portlib)
>
> so i tried to add
>
> LINK_LIBRARIES(wsock32 ws2_32)
>
> to the portlib CMakeLists.txt but this didn't work as i hoped.
Usually if you use TARGET_LINK_LIBRARIES, CMake will handle the dependencies
automatically
ADD_LIBRARY(portlib ${portlib_srcs} ${portlib_public_hdrs})
IF(WIN32)
TARGET_LINK_LIBRARIES(portlib ws2_32)
ENDIF()
ADD_EXECUTABLE(foo foo.cc)
TARGET_LINK_LIBRARIES(foo portlib) # on WIN32, will be linked against ws2_32
as well
--
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080715/1f0c2fe6/attachment-0001.htm>
More information about the CMake
mailing list