I am building a Qt application on Windows using static Qt build made with MinGW and using MinGW to compile the application itself too (MinGW wasn’t my choice, unfortunately I have to use it for this project).
The application builds fine with both qmake and CMake, but the resulting executable is different when it is built using qmake and when it is built using CMake. In particular, the imports are different:
As you can see, the executable built with CMake requires some more DLLs for runtime, while executable built with qmake does not require those. In practice this means that I can run the qmake-produced executable and it will launch fine without complaining about missing DLLs, but CMake-produced executable will complain about missing MinGW runtime DLLs, zstd DLL (and likely zlib DLL too).
The Qt is built with
-static-runtime option, so the application shouldn’t require MinGW runtime DLLs (and it doesn’t require those with qmake, as expected), but okay, that could probably be “fixed” for CMake like this:
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
Most probably similar “workarounds” would apply to zstd and zlib, although I don’t get how all of a sudden these are shared libraries, because qmake should’ve encountered the same problem, but it hasn’t, so it used static variants somehow.
And so the point/question is, what does qmake do behind the scenes for MinGW builds, so developer doesn’t need to care about such things? Is there some “magic” property for Qt projects in CMake which would do the same?
For the reference, here are my project files: