Search code examples
qtcopyinstallationqmake

qmake copy files created while building


I've got a library qmake project:

QT       += gui

TARGET = qturtle
TEMPLATE = lib

DEFINES += QTURTLE_LIBRARY

SOURCES += qturtle.cpp

HEADERS += qturtle.h\
        qturtle_global.h

docMake.commands = doxygen;
QMAKE_EXTRA_TARGETS += docMake
PRE_TARGETDEPS += docMake
QMAKE_DISTCLEAN += $$PWD/html/ -r
QMAKE_DISTCLEAN += doxygen_sqlite3.db

unix {
    docInstall.path = /usr/share/doc/qturtle
    docInstall.files = $$PWD/html/

    headerInstall.files = $$HEADERS
    headerInstall.path = /usr/include/qturtle

    target.path = /usr/lib

    INSTALLS += docInstall
    INSTALLS += target
    INSTALLS += headerInstall
}

docMake runs doxygen in the project directory, and creates the 'html' directory and its contents ( during build!) 'html' and its contents now should be copied to /usr/share/doc/qturtle, using the INSTALL variable. BUT: qmake doesn't generate any code for docInstall install, because $$PWD/html and its contents do not exist during makefile generation. Could anybody tell me how to avoid this problem, or do I have to use cp?

Thanks in advance, Marius


Solution

  • There are two approaches to address this problem.

    Not to check againt the initially empty directory

    docInstall.CONFIG += no_check_exist directory
    

    Since this directory will be created on the fly, I would personally opt for this.

    Create the directory explicitly

    createDirs.commands = $$QMAKE_MKDIR $$PWD/html
    

    This could be done either in a target or even in a system("$$QMAKE_MKDIR $$PWD/html") call, depending on your needs.