I have a static version of QT compiled like this:
@echo off
SET QTDIR=%~dp0%
SET QMAKESPEC=win32-g++
SET PATH=%PATH%;%QTDIR%/gcc
call configure -release -nomake examples -nomake tools -static -static-runtime -opensource -confirm-license -platform win32-g++ -ltcg -c++std c++11 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -fontconfig -qt-harfbuzz -qt-sql-sqlite -prefix %QTDIR%/gcc
mingw32-make -j4
mingw32-make install
And I have a sample program that look like this:
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCore/QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
int main(int argc, char** argv){
QApplication app(argc, argv);
QMainWindow w;
w.resize(600,600);
w.show();
app.exec();
return 0;
}
Now when I try to compile it with cmake like this:
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 "main.cpp")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} Qt5Widgets qwindows Qt5Gui Qt5Core qtmain Qt5Gui Qt5OpenGL Qt5OpenGLExtensions Qt5PlatformSupport qtfreetype dxguid d3d9 d3dx9 imm32 winmm Qt5WinExtras libEGL ws2_32 translator qtpcre libGLESv2 qtharfbuzzng preprocessor )
It works! But note the duplicated Qt5Gui in the early end of the line? If I take out either one and compile, I ended up with TONS of undefined reference link errors.
I wonder how can I figure out the correct order! Thanks!
TARGET_LINK_LIBRARIESdirective twice. Haven't tried it recently, can't be sure that it still works (and that it works withcmake).