Loading dlls using qtwindowdeploy
-
Hello everyone!
I have a project and I need to prepare a CMakeLists.txt file for it.
I also have tests which I need to get an executables for after building the project.Tests are located in a separate
backEndTestfolder with their own CMakeLists.txt file.
In order to achieve that I decided to useqtwindeploytool for that. However, when I compile everything and try to runbackEndText.exefile I have errors related to missing dlls.That's what my main CMakeLists.txt file looks like:
add_subdirectory(backEndTest) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test) set(QtBinDir "C:/Qt/6.2.3/mingw_64/bin") set(winDeploy "${QtBinDir}/windeployqt.exe") set(backEndTest ${CMAKE_BINARY_DIR}/backEndTest/backEndTest.exe) set(testBackEnd TRUE) if (testBackEnd) execute_process(COMMAND ${winDeploy} ${backEndTest} --compiler-runtime ) endif()Do you have any idea why dlls are not getting linked?
-
execute_process() is a command that will be immediately executed when CMake is run. But at this time backEndTest.exe has not been built yet.
What you should do is schedule the run of windeployqt after backEndTest.exe has been generated, e.g. with a add_custom_command().
If you are using Qt 6.3, you can also consider using qt_generate_deploy_app_script()
-
execute_process() is a command that will be immediately executed when CMake is run. But at this time backEndTest.exe has not been built yet.
What you should do is schedule the run of windeployqt after backEndTest.exe has been generated, e.g. with a add_custom_command().
If you are using Qt 6.3, you can also consider using qt_generate_deploy_app_script()
@kkoehne this seems to be as a quite nice solution. Could you guide me on how to add this custom command to run after backEndTest.exe is created, please?