Quick update to this post, since we ended up figuring the issue out directly via email. Note we're talking about CMake, which is not the same program as QMake.
It appears the issue was caused by an erroneous call to include_directories using relative paths. However - and that may interest other CMake users on Windows - even after compiling successfully, the executable complained it could not find Qt DLLs (Qt5Core.dll, Qt5Widgets.dll, Qt5Gui.dll) or could not find a specific "entry point".
In addition to the steps described in the official Qt documentation, we needed to
- Make sure the same version of MinGW as the one provided by Qt was used. It could be found under the following path: C:\Qt\Tools\mingw730_32 (bin folder for g++).
- Call the windeployqt utility shipped with Qt (found under C:\Qt\5.14.1\bin). It will scan your executable and copy required Qt dependencies to the same folder (such as the DLL files mentioned above). Make sure that when calling this program, g++ as provided by Qt is in the path.
Those manipulations seem to be necessary only on Windows systems (MacOS reportedly worked out of the box). A modular CMakeLists.txt can conveniently be achieved by wrapping Windows specific code with:
if(WIN32)
#Windows only code here
endif()
Lastly, it is useful to have windeployqt called after each build, which can be achieved with the following CMake lines. Each word in italic needs to be adapted to your setup.
add_custom_command(TARGET yourMainTargetName POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env PATH="pathToQtBinFolder;pathToQtMinGW"
COMMAND ${CMAKE_COMMAND} -E env PATH="pathToQtBinFolder;pathToQtMinGW"
pathToWindeployqt $<TARGET_FILE:yourMainTargetName>
COMMENT "Running windeployqt")