[CMake] patch : Qt Static on windows

Clinton Stimpson clinton at elemtech.com
Fri May 12 11:44:23 EDT 2006


 > From: John Biddiscombe <biddisco at cscs.ch>
 > Subject: [CMake] patch : Qt Static on windows
 > To: cmake at cmake.org
 >
 > I've submitted earlier a new bug report
 > ---------
 > #bug3222
 > Building QT as a static build on windows causes Qvtk and anything else
 > that uses Qt to fail due to linker errors.
 > The reason is because the Find and UseQt4 scripts set all the
 > -DQT_CORE_LIB flags so that the exports are declared as DLL type and the
 > static link fails.
 >
 > Also additional libs are required when linking against Qt static
 >
 > IF (WIN32 AND QT_STATIC)
 > TARGET_LINK_LIBRARIES( QVTKWidgetPlugin Imm32 Winmm Ws2_32)
 > ENDIF (WIN32 AND QT_STATIC)
 > ------------
 >
 > Attached is a patch which fixes the problem on my system.
 > In Find Qt we Glob the QT_BINARY_DIR and if there are no DLLs in there,
 > we can probably assume it was a static build. We Set QT_STATIC and then
 > in UseQt we do not set the CORE_LIB, GUI_LIB etc flags if we are static,
 > thus preventing bogus link. Also suppress QT_DLL if static.
 >
 > If anyone knows of a better way of checking for QT_STATIC other than
 > searching for DLL's - I can't find a QMake - query that will tell me
 >
 > Please check patch and apply.
 >
 > JB

How about checking  the .prl file for whether Qt is built as shared 
libraries or not.  That file holds valuable information about the Qt 
configuration.
The real thing your patch does is not set QT_DLL if it is a static Qt 
library.  That is all that should be necessary.

Grepping through the public Qt headers, QT_GUI_LIB is found in only one 
header file.  It should always be set if using the QtGui library, so 
that some features that combine QtGui and QtSql can be used.
The other QT_*_LIB defines are probably bogus, and should probably be 
removed entirely.

Clint



More information about the CMake mailing list