[CMake] FindQt4 QT_LIBRARIES

John Drescher drescherjm at gmail.com
Thu Jul 29 15:41:01 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;optimized;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


More information about the CMake mailing list