[CMake] Finding Debug Versions of Qt4 Frameworks on OS X

Michael Jackson mike.jackson at bluequartz.net
Mon Jul 19 16:54:54 EDT 2010


On Jul 19, 2010, at 4:28 PM, Michael Wild wrote:

>
> On 19. Jul, 2010, at 19:59 , Michael Jackson wrote:
>
>> Wonder why I have never seen this before but with CMake 2.8.x and a  
>> Qt4 based project on OS X when finding the Qt4 frameworks only the  
>> release version is found, ie, the Debug version that is located  
>> inside the framework is NOT found by default.
>> My question is: is this a bug, a "feature" or should I be using the  
>> DYLD_IMAGE_SUFFIX environment variable instead?
>>
>> The offending code is in the FindQt4.cmake file around lines 772:
>>
>> FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_DEBUG
>>                NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}$ 
>> {QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4
>>                PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH
>>       )
>>
>> I would imagine that the cmake code above is going to try and find  
>> QtCore_debug.framework and NOT QtCore.framework/versions/current/ 
>> QtCore_debug
>>
>> Thoughts?
>> ___________________________________________________________
>> Mike Jackson                      www.bluequartz.net
>> Principal Software Engineer       mike.jackson at bluequartz.net
>> BlueQuartz Software               Dayton, Ohio
>
> Reading http://doc.trolltech.com/4.6/mac-differences.html#qt-libraries-as-frameworks 
>  seems to indicate that either setting DYLD_IMAGE_SUFFIX is one way  
> to go, renaming the embedded library another. Not sure it would be  
> all that desirable to explicitly link against the debug versions on  
> Mac OS X...
>
> Michael

Knowing how CMake was searching for the frameworks I ended up creating  
some symlinks to the QtCore.framework and QtGui.framework.
QtCore_debug.framework points to QtCore.framework and the same for the  
other frameworks. This actually allowed CMake to find the debug  
libraries. Once those libraries were found I could then actually link  
against the debug versions. Which allows me to debug down into Qt  
itself which is what I needed.
    I agree that if you trust Qt and have no need to debug down into  
Qt then linking against the Debug versions probably is not needed.  
Setting the DYLD_IMAGE_SUFFIX environment variable to "_debug" caused  
the launching of my app inside gdb to go from about 10 seconds to 2  
minutes as gdb was trying to load the debug version of every library  
that the app links against, plus all of their dependencies. By linking  
directly to the debug versions of the Qt libraries the launch times  
only increased a small amount.
   I don't think there is really any type of patch that I could  
submit. Merely creating the symlinks in the Qt/lib installation  
directory seems to have solved the issue, at least for me.

Thanks for the sanity check
Mike Jackson







More information about the CMake mailing list