[CMake] Choosing between debug and release variants of third-party
libraries
Philip Lowman
philip at yhbt.com
Fri Nov 9 20:41:08 EST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Torsten Martinsen wrote:
> Philip Lowman <mailto:philip at yhbt.com> wrote:
>
>> Torsten Martinsen wrote:
>>> I'm sure this is a FAQ, but I cannot find the answer anywhere.
>>>
>>> Using VS 2003, given that I have a third-party library with debug
>>> and release variants:
>>>
>>> /path/to/lib/release/lib.lib
>>> /path/to/lib/debug/lib.lib
>>>
>>> how do I get CMake to link with the correct variant? Using an
>>> absolute path in TARGET_LINK_LIBRARIES() does not work, and I cannot
>>> use CMAKE_BUILD_TYPE at configure time.
>> # TARGET_LINK_LIBRARIES: Link a target to given libraries.
>>
>> TARGET_LINK_LIBRARIES(target library1
>> <debug | optimized> library2
>> ...)
>
> That's what I tried, but the third-party libraries are located outside my build tree, so I need to use absolute paths, which as I said does not work:
>
> It is impossible to order the linker search path in such a way that libraries specified as full paths will be picked by the linker.
> Directories and libraries involved are:
> Directory: c:/lang/Qt/3.3.4/lib contains:
> Library: c:\lang\qt\3.3.4r/lib/qtmain.lib
>
> Directory: c:/lang/qt/3.3.4r/lib contains:
> Library: C:\lang\Qt\3.3.4/lib/qtmain.lib
So you can't do something like this?
FIND_LIBRARY(qtmain_release qtmain
PATHS "C:/lang/qt/3.3.4r/lib" NO_DEFAULT_PATH)
FIND_LIBRARY(qtmain_debug qtmain
PATHS "C:/lang/qt/3.3.4/lib" NO_DEFAULT_PATH)
# declare your targets.....
TARGET_LINK_LIBRARIES(foo release ${qtmain_release})
TARGET_LINK_LIBRARIES(food debug ${qtmain_debug})
If something like that doesn't work I would file a bug for sure.
- --
Philip Lowman
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHNQw0e0tOktX6RKkRAunbAJ9gFrY35h6qotT1nifV5wD9EvRfbgCdHXrY
BD5vex/wKPBb6XuVt3v41vY=
=i5ci
-----END PGP SIGNATURE-----
More information about the CMake
mailing list