How to improve the DLL management

Hi there,

I am currently developing some unit and integration tests that are dependent on Qt6. Right now I am using the following custom command to copy and paste the DLLs needed to execute the test on the CI machine.

    get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
    get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
    find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
    find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")

    add_custom_command(TARGET UnitTest POST_BUILD
            COMMAND "${CMAKE_COMMAND}" -E
            env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
            --no-translations
            "$<TARGET_FILE:UnitTest>"
            COMMENT "Running windeployqt...")

This is done for each test that it’s depending on external DLLs. The code above is even copying MVSC DLLs…

I am wondering how I can improve the way of handling the DLLs, is there any way to just load the DLL at execution time and link it to execute the test?

If I continue doing it in this way I will have a hundred DLLs around the place which are going to fill my hard disk at some point.

Thank you so much in advance,
xhustago

You could add the Qt path to PATH. There is also the $<TARGET_RUNTIME_DLLS> genex, but this will not handle Qt plugins at all (which, I believe, is the benefit of windeployqt).

Yes, locally I have Qt/bin in the path. Same for OpenCV for example. For the CI is not enough.
I’ll check the $<TARGET_RUNTIME_DLLS>.