[CMake] FindQt4 QT_LIBRARIES

Hicham Mouline hicham at mouline.org
Thu Jul 29 16:11:53 EDT 2010


>>> Hello,I have looked at  FindQt4.cmake module for 2.8.2, but I can't find
the code that sets the QT_LIBRARIES variable.Could someone point that
out?Regards
>
>>It's in UseQt4.cmake.
>
>>HTH
>
>>Michael
>
> I am now trying to link against QT debug libariries in the RelWithDebInfo
cmake configuation case.
> However, it links against the QT release libs when I follow those lines of
help of FindQt4.cmake that describe the typical usage.
> This is the cmake code:
> FIND_PACKAGE(Qt4 4.5.3 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
> INCLUDE(${QT_USE_FILE})
> TARGET_LINK_LIBRARIES(main ${QT_LIBRARIES})
>
> 1. when CMAKE_BUILD_TYPE is Release, vs2008 shows the release libs of qt
> 2. when CMAKE_BUILD_TYPE is Debug, vs2008 shows the debug libs of qt
> 3. However when CMAKE_BUILD_TYPE is RelWithDebInfo it picks the release qt
libs where I'd want to pick the debug qt libs. Outputting QT_LIBRARIES
shows:
>
optimized;C:/Qt/4.6.0/lib/QtOpenGL4.lib;debug;C:/Qt/4.6.0/lib/QtOpenGLd4.lib
;optimized;C:/Qt/4.6.0/lib/QtGui4.lib;debug;C:/Qt/4.6.0/lib/QtGuid4.lib;opti
mized;C:/Qt/4.6.0/lib/QtCore4.lib;debug;C:/Qt/4.6.0/lib/QtCored4.lib
>

That will most likely cause your application to crash. You can not mix
debug and release crt. Well at least I spent days figuring out why my
simple qt dialog was crashing for no apparent reason. Then found that
one of the dependencies was causing a mix of debug and release libs.

John

----

It does crash currently with release libs for relwithdebingfo config. If I
link against debug libs, it doesn't crash.
The question is: when config is relwithdebingfo, how can I get
TARGET_LINK_LIBRARIES to pick the debug version of the libs from
QT_LIBRARIES?

rds,



More information about the CMake mailing list