[CMake] Linking against debug/release libraries on Windows depending on build type

Mike Jackson imikejackson at gmail.com
Wed Jun 18 13:09:03 EDT 2008


I would suggest studying the FindQt4.cmake file carefully. What  
basically happens is that the dlls for Qt for debug and release are  
found (because they follow a well know naming convention), then 3  
variables are created. Take for example QtCore. You will have the  
following (or something very close):

QTCORE_DEBUG_LIBRARY =
QTCORE_RELEASE_LIBRARY =
QTCORE_LIBRARY =

There is a macro that then looks are your build type and decides  
which of the libraries to put in for QTCORE_LIBRARY, which is then  
added to the QT_LIBRARIES variable, and which your code will  
eventually link.

Me, and probably others, have taken that design style for cmake and  
used it for our own needs. Currently I have to build HDF5, Tiff, and  
Expat for my project and I use that same idea to build debug and  
release versions for windows to link against. Again, I use my own  
naming convention and stick to it and all seems to work.

Check the last script I sent. It can probably be modified to pick up  
the Qt libs that you want.

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jun 18, 2008, at 12:56 PM, Mike Arthur wrote:

> Is there some magical way (or can anyone suggest how to implement)  
> CMake can
> know that, for a debug build, it wants to link against
> ${FILENAMEWITHOUTEXTENSION}d.lib and for a release build against
> ${FILENAMEWITHOUTEXTENSION}.lib?
>
> Double points if anyone also can suggest how I'd install the DLL  
> versions of
> those libraries also (the same filename but with a .dll extension  
> rather
> than .lib)
>
> Any other UNIX coders having to hack their CMakeLists to cater for  
> Visual
> Studio's idiocies please raise your hands...
>
> Thanks in advance!
>
> -- 
> Cheers,
> Mike Arthur
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list