[CMake] using only release versions of QT libraries

Michael Hertling mhertling at online.de
Thu Sep 9 21:09:43 EDT 2010


On 09/09/2010 09:06 PM, edA-qa mort-ora-y wrote:
> My cmake file has the fairly standard QT setup:
> 
> find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtNetwork QtSvg QtOpenGL
> QtMain REQUIRED)
> include(${QT_USE_FILE})
> 
> 
> and then later use ${QT_LIBRARIES}
> 
> However, this uses the debug libraries when I do a debug build. I don't
> want that. I want to just use the Release libraries for QT. Is there an
> easy way to do this?

You could use imported targets and set the IMPORTED_LOCATION_DEBUG
properties to IMPORTED_LOCATION_RELEASE for each Qt module, e.g.:

SET(QT_USE_IMPORTED_TARGETS TRUE)
FIND_PACKAGE(Qt4 ...)
INCLUDE(${QT_USE_FILE})
FOREACH(i IN LISTS QT_LIBRARIES)
    GET_TARGET_PROPERTY(p ${i} IMPORTED_LOCATION_RELEASE)
    SET_TARGET_PROPERTIES(${i} PROPERTIES IMPORTED_LOCATION_DEBUG ${p})
ENDFOREACH()

Anyway, take John's warning seriously.

Regards,

Michael


More information about the CMake mailing list