<div dir="ltr">On Tue, Jul 15, 2008 at 11:09 AM, Hauke Heibel <<a href="mailto:heibel@cs.tum.edu">heibel@cs.tum.edu</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;"><div bgcolor="#ffffff" text="#000000"><div class="Ih2E3d"><blockquote type="cite">
<div dir="ltr">
<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;">And
the last question is, if it is possible to tell the FindQt.cmake script
to give me the plain libraries without the full path of them being
prepended (I am talking about the content of the QT_LIBRARIES
variable). I would rather like to use LINK_DIRECTORIES and
TARGET_LINK_LIBRARIES separately, i.e. I would prefer QtGuid4.lib over
C:\Qt\lib\QtGuid4.lib.</blockquote>
<div><br>
It should be possible to do this with STRING(REGEX REPLACE... ) if
there is no better way. I'm curious why you would need to do this
though. The use of TARGET_LINK_LIBRARIES() with full paths is highly
desired over LINK_LIBRARIES() and TARGET_LINK_LIBRARIES() with a
relative library filename.</div>
</div>
</div>
</blockquote></div>
Ok, I see what you mean though I am wondering why in general not all
CMake Find modules follow this paradigm. For instance all of my ITK
libraries seem to be set via TARGET_LINK_LIBRARIES() without the path
and the path (here luckily including the $(OutDir), which I just
realized) seems to be set via LINK_DIRECTORIES(). Maybe it is done that
way to support the multi-target MSVC generator because
LINK_DIRECTORIES() does not (yet?) support the CONFIGURATIONS option.</div></blockquote><div><br>This is probably a good theory as to why it's done this way. It's one of the downsides of CMake that using it for MSVC is not quite as straightforward as using it on other compilers.<br>
<br>To really use CMake properly with VS generated libraries (which have the release vs. release and debug vs. debug linking requirement) you either have to add extra calls to FIND_LIBRARY() to find the Debug libraries with an appended "d" (most CMake find modules don't do this on their own) or use a hack like this:<br>
<br>FIND_LIBRARY(MYMATH_LIBRARY mymath)<br>ADD_EXECUTABLE(foo foo.cc)<br>IF(MSVC)<br> STRING(REPLACE ".lib" "d.lib" MYMATH_DEBUG_LIBRARY ${MYMATH_LIBRARY})<br> TARGET_LINK_LIBRARIES(foo optimized ${MYMATH_LIBRARY} debug ${MYMATH_DEBUG_LIBRARY})<br>
ELSE()<br> TARGET_LINK_LIBRARIES(foo ${MYMATH_LIBRARY})<br>ENDIF()<br></div></div><br><br>-- <br>Philip Lowman
</div>