<div dir="ltr">On Tue, Jul 15, 2008 at 4:53 AM, Jack Andrews <<a href="mailto:effbiae@gmail.com">effbiae@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hi guys,<br>
<br>
i've got a small library (portlib) that does things including sockets<br>
on linux and windows. my problem is that many executables depend on<br>
this library and it seems that for every executable i also have to add<br>
<br>
IF(WIN32)<br>
LINK_LIBRARIES(wsock32 ws2_32 portlib)<br>
ENDIF(WIN32)<br>
<br>
that is, on top of portlib, i have to specify windows libs. i can't<br>
seem to work out how i can get away with just:<br>
<br>
LINK_LIBRARIES(portlib)<br>
<br>
so i tried to add<br>
<br>
LINK_LIBRARIES(wsock32 ws2_32)<br>
<br>
to the portlib CMakeLists.txt but this didn't work as i hoped.</blockquote><div><br>Usually if you use TARGET_LINK_LIBRARIES, CMake will handle the dependencies automatically<br><br>ADD_LIBRARY(portlib ${portlib_srcs} ${portlib_public_hdrs})<br>
IF(WIN32)<br> TARGET_LINK_LIBRARIES(portlib ws2_32)<br>ENDIF()<br><br><br>ADD_EXECUTABLE(foo foo.cc)<br>TARGET_LINK_LIBRARIES(foo portlib) # on WIN32, will be linked against ws2_32 as well<br></div></div><br><br>-- <br>
Philip Lowman
</div>