Search code examples
c++qtdllinstallationqmake

Install dll into 2 targets (paths) with qmake


Have following qt pro file:

CONFIG      += plugin debug_and_release
TARGET      = $$qtLibraryTarget(WidgetBoxPlugin)
TEMPLATE    = lib
...
target.path = $$[QT_INSTALL_PLUGINS]/designer
creator_target.path = $$[QTCREATOR_BIN_PATH]/plugins/designer
INSTALLS    += target creator_target

And resulted dll file was copied into 2 paths (targets). Now it does not work for some reason: qmake does not generate install (copy) script for 2nd target (QTCREATOR_BIN_PATH is set). How to write 2nd install correctly so dll being installed into 2 destinations?

Full project: https://github.com/akontsevich/WidgetBox


Solution

  • Got suggestion here: https://forum.qt.io/topic/66090/qmake-does-not-generate-2nd-install-target-in-makefile/3#

    According to documentation (https://wiki.qt.io/QMake-top-level-srcdir-and-builddir) correct build dir macro is $$OUT_PWD, so correct installation code is:

    target.path = $$[QT_INSTALL_PLUGINS]/designer
    
    creator_target.name = Copying the target dll to Qt Creator plugins directory as well
    creator_target.input = $qtLbraryTarget(WidgetBoxPlugin)
    creator_target.path  = $$(QTCREATOR_BIN_PATH)/plugins/designer
    creator_target.CONFIG += no_check_exist
    creator_target.output = WidgetBoxPlugin.dll
    creator_target.files = $$OUT_PWD/release/WidgetBoxPlugin.dll
    QMAKE_EXTRA_COMPILERS += creator_target
    
    INSTALLS += target creator_target
    

    Only strange why [] brackets only work for target and () are necessary for creator_target?