Search code examples
qtqmakeqt6

How to copy built DLL from one SUBDIR to another?


I have following project architecture

project.pro
|
|--app.pro
|
|--lib1.pro
|
|--lib2.pro

lib1 is a shared library. lib2 depends on lib1.

app depends on lib1 and lib2

project.pro:

SUBDIRS = \
         app \
         lib1 \
         lib2 \

# Introduce sub projects
app.subdir = src/app
lib1.subdir = src/core/lib1
lib2.subdir = src/core/lib2

# Make app dependent from lib1 and lib2
# This way lib1 and lib2 get build first
lib2.depends = lib1
app.depends = lib1 lib2

Now, lib1 builds fine. But lib1.pro is unable to copy lib1.dll to lib2 folder. I tried being proactive in lib1.pro and create lib2 folder and copy the dll. And vise versa. The ways for copying I tried are

CONFIG += file_copies,

INSTALLS +=... (I added make install as additional build step in QtCreator)

QMAKE_POST_LINK with the correct copy cmd

I even checked with qmake exists() if lib1.dll is created before trying to copy it. The file is created every time.

Anyone has an idea? Kind Regards


Solution

  • Solution:

    lib1.pro
    
    TARGET = lib1
    TEMPLATE = lib
    DESTDIR = $$OUT_PWD/../bin
    
    lib2.pro
    
    INCLUDEPATH += $$OUT_PWD/../bin
    LIBS += -L$$OUT_PWD/../bin -llib1