I want to copy files to the build folder (when shadow building is enabled). I created this script that uses "make install", but it copies the files each time the executable is compiled. Instead, I would like it to copy files only if those in source directory are newer than those in build directory.
In this working script, a database file and translation files are copied:
TRANSLATIONS = translations/app_pl_pl.ts
CODECFORTR = UTF-8
# add commands to QMake for execution after linking the file
# in this case, compiling translations
QMAKE_POST_LINK += lrelease $$_PRO_FILE_ && \
lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
# if shadow building is enabled
!equals(PWD, $${OUT_PWD}) {
# prepare copying files from the current directory to the output directory
# copy database file
DATABASE.files = data/Database.db3
DATABASE.path = $${OUT_PWD}/data
DATABASE.CONFIG += no_check_exist
INSTALLS += DATABASE
# copy compiled translations
COMPILED_TRANSLATIONS.files = translations/app_pl_pl.qm \
translations/qt_pl.qm
COMPILED_TRANSLATIONS.path = $${OUT_PWD}/translations
COMPILED_TRANSLATIONS.CONFIG += no_check_exist
INSTALLS += COMPILED_TRANSLATIONS
# add installing (copying) files
QMAKE_POST_LINK += && make install
}
TRANSLATIONS = translations/app_pl_pl.ts
CODECFORTR = UTF-8
# add commands to QMake for execution after linking the file
# in this case, compiling translations
QMAKE_POST_LINK += lrelease $$_PRO_FILE_ && \
lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
# if shadow building is enabled
!equals(PWD, $${OUT_PWD}) {
# prepare copying files from the current directory to the output directory
# copy database file
DATABASE.files = data/Database.db3
DATABASE.path = $${OUT_PWD}/data
DATABASE.CONFIG += no_check_exist
INSTALLS += DATABASE
# copy compiled translations
COMPILED_TRANSLATIONS.files = translations/app_pl_pl.qm \
translations/qt_pl.qm
COMPILED_TRANSLATIONS.path = $${OUT_PWD}/translations
COMPILED_TRANSLATIONS.CONFIG += no_check_exist
INSTALLS += COMPILED_TRANSLATIONS
# add installing (copying) files
QMAKE_POST_LINK += && make install
}
To copy to clipboard, switch view to plain text mode
I also tried with QMAKE_EXTRA_COMPILERS and QMAKE_INSTALL_FILE, but couldn't make it work. Here are my attempts, some of them don't even compile:
DATABASE.files = data/Database.db3
COPYING.input = DATABASE
COPYING.output = ${OUT_PWD}/${QMAKE_FILE_IN}
COPYING.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
COPYING.name = COPY ${QMAKE_FILE_IN}
COPYING.CONFIG += no_check_exist
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPYING.input = $${PWD}/translations/qt_pl.qm
COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
COPYING.commands = $$QMAKE_INSTALL_FILE $${QMAKE_FILE_NAME} $${QMAKE_FILE_OUT}
COPYING.depend_command = lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPYING.input = $${PWD}/translations/qt_pl.qm
COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
COPYING.commands = $${QMAKE_INSTALL_FILE} $${PWD}/translations/qt_pl.qm $${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPIES = $${PWD}/translations/qt_pl.qm
COPYING.input = COPIES
COPYING.output = $${OUT_PWD}/$${QMAKE_FILE_BASE}
COPYING.commands = $$QMAKE_INSTALL_FILE ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += COPYING
DATABASE.files = data/Database.db3
COPYING.input = DATABASE
COPYING.output = ${OUT_PWD}/${QMAKE_FILE_IN}
COPYING.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
COPYING.name = COPY ${QMAKE_FILE_IN}
COPYING.CONFIG += no_check_exist
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPYING.input = $${PWD}/translations/qt_pl.qm
COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
COPYING.commands = $$QMAKE_INSTALL_FILE $${QMAKE_FILE_NAME} $${QMAKE_FILE_OUT}
COPYING.depend_command = lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPYING.input = $${PWD}/translations/qt_pl.qm
COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
COPYING.commands = $${QMAKE_INSTALL_FILE} $${PWD}/translations/qt_pl.qm $${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += COPYING
---------------------
COPIES = $${PWD}/translations/qt_pl.qm
COPYING.input = COPIES
COPYING.output = $${OUT_PWD}/$${QMAKE_FILE_BASE}
COPYING.commands = $$QMAKE_INSTALL_FILE ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += COPYING
To copy to clipboard, switch view to plain text mode
I know Cmake allows to check file's modification date and copy them easily with two simple functions. Isn't this possible in Qmake?
Bookmarks