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:
Qt Code:
  1. TRANSLATIONS = translations/app_pl_pl.ts
  2. CODECFORTR = UTF-8
  3.  
  4. # add commands to QMake for execution after linking the file
  5. # in this case, compiling translations
  6. QMAKE_POST_LINK += lrelease $$_PRO_FILE_ && \
  7. lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
  8.  
  9. # if shadow building is enabled
  10. !equals(PWD, $${OUT_PWD}) {
  11.  
  12. # prepare copying files from the current directory to the output directory
  13.  
  14. # copy database file
  15. DATABASE.files = data/Database.db3
  16. DATABASE.path = $${OUT_PWD}/data
  17. DATABASE.CONFIG += no_check_exist
  18. INSTALLS += DATABASE
  19.  
  20. # copy compiled translations
  21. COMPILED_TRANSLATIONS.files = translations/app_pl_pl.qm \
  22. translations/qt_pl.qm
  23. COMPILED_TRANSLATIONS.path = $${OUT_PWD}/translations
  24. COMPILED_TRANSLATIONS.CONFIG += no_check_exist
  25. INSTALLS += COMPILED_TRANSLATIONS
  26.  
  27. # add installing (copying) files
  28. QMAKE_POST_LINK += && make install
  29. }
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:

Qt Code:
  1. DATABASE.files = data/Database.db3
  2. COPYING.input = DATABASE
  3. COPYING.output = ${OUT_PWD}/${QMAKE_FILE_IN}
  4. COPYING.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
  5. COPYING.name = COPY ${QMAKE_FILE_IN}
  6. COPYING.CONFIG += no_check_exist
  7. QMAKE_EXTRA_COMPILERS += COPYING
  8.  
  9. ---------------------
  10.  
  11. COPYING.input = $${PWD}/translations/qt_pl.qm
  12. COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
  13. COPYING.commands = $$QMAKE_INSTALL_FILE $${QMAKE_FILE_NAME} $${QMAKE_FILE_OUT}
  14. COPYING.depend_command = lrelease $$PWD/translations/qt_pl.ts -qm $$PWD/translations/qt_pl.qm
  15. QMAKE_EXTRA_COMPILERS += COPYING
  16.  
  17. ---------------------
  18.  
  19. COPYING.input = $${PWD}/translations/qt_pl.qm
  20. COPYING.output = $${OUT_PWD}/translations/qt_pl.qm
  21. COPYING.commands = $${QMAKE_INSTALL_FILE} $${PWD}/translations/qt_pl.qm $${QMAKE_FILE_OUT}
  22. QMAKE_EXTRA_COMPILERS += COPYING
  23.  
  24. ---------------------
  25.  
  26. COPIES = $${PWD}/translations/qt_pl.qm
  27. COPYING.input = COPIES
  28. COPYING.output = $${OUT_PWD}/$${QMAKE_FILE_BASE}
  29. COPYING.commands = $$QMAKE_INSTALL_FILE ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
  30. 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?