[CMake] Three short questions...

Philip Lowman philip at yhbt.com
Tue Jul 15 07:37:38 EDT 2008

On Tue, Jul 15, 2008 at 4:17 AM, Hauke Heibel <heibel at cs.tum.edu> wrote:

> Hi there,
> I've stumbled over three little questions which I could not answer from the
> FAQs nor the CMake documentation or the Wiki. Maybe one of the specialists
> can help me out...
> The first question is whether it is possible to prevent environment
> variables from being expanded by CMake when it comes to setting include or

Not sure what you mean here.  You might be able to do this (don't know,
never tried), but I wouldn't recommend it:


> The second question is whether I can prevent the MSVC generator to append
> $(OutDir) to LINK_DIRECTORIES. For each call to LINK_DIRECTORIES I get two
> directories (e.g. LINK_DIRECTORIES(c:/foo/bar) creates c:/foo/bar/$(OutDir)
> and c:/foo/bar).

I didn't even realize that it did that.  I think that's probably meant as a
convenience for MSVC developers who sometimes like to share the same
filename across different release configurations (in different directories
obviously).   Not sure if it's disableable or not, is it causing you

> 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.

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.  It allows you to support use cases like this:

If you have two external packages that both provide "sys.lib" for example..
...there is no way to link them both in using LINK_DIRECTORIES() and
TARGET_LINK_LIBRARIES().  If you only want one trying to figure out which
one you want is usually impossible if for other reasons you need other
libraries from both C:\foo and C:\bar.  If on the other hand you're using
TARGET_LINK_LIBRARIES with full paths the linker should be able to figure
everything out since most linkers support full paths to libraries.

Usually people just use the absolute paths determined by CMake Find modules
or by manual calls to FIND_LIBRARY().  There are several variables that you
can modify prior to calling FIND_LIBRARY() or FIND_PACKAGE() that will
usually allow you to override the default directory search paths.  See


Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080715/d98168d1/attachment.htm>

More information about the CMake mailing list