I wrote this code to detect if shadow building is enabled - and when it is, copy some files to the output directory. It works, but...

... it always thinks the shadow building is enabled, even when I build in the same directory as my project. I believe the problem lies within contains() function, which always invokes code inside its scope.

Here's the revelant code in my .pro file:

Qt Code:
  1. # if shadow building is enabled
  2. !contains($${PWD}, $${OUT_PWD}) {
  3.  
  4. # copy files from the current directory to the output directory
  5.  
  6. # some stuff
  7. }
To copy to clipboard, switch view to plain text mode 

Maybe there is a better way of detecting shadow building and moving necessary files? I don't want to use INSTALLS because it's supposed to install the app on one's system, not to help developing.


And here is the real code if anyone is interested in how the copying of files is done (currently adjusted for Windows):
Qt Code:
  1. # compile translations
  2. QMAKE_POST_LINK += lrelease $$_PRO_FILE_
  3.  
  4. # if shadow building is enabled
  5. !contains($${PWD}, $${OUT_PWD}) {
  6.  
  7. # copy files from the current directory to the output directory
  8. win32 {
  9. CHECK_DIR_EXIST = if exist
  10. MAKE_DIR = mkdir
  11. COPY = copy /y
  12. }
  13.  
  14. # specify files for copying
  15. COMPILED_TRANSLATIONS_SOURCE = $${PWD}/translations/$${TARGET}_pl_PL.qm
  16. COMPILED_TRANSLATIONS_DEST = $${OUT_PWD}/translations
  17.  
  18. # replace '/' with '\' in Windows paths
  19. win32 {
  20. COMPILED_TRANSLATIONS_SOURCE = $${replace(COMPILED_TRANSLATIONS_SOURCE, /, \)}
  21. COMPILED_TRANSLATIONS_DEST = $${replace(COMPILED_TRANSLATIONS_DEST, /, \)}
  22. }
  23.  
  24. CHECK_COMPILED_TRANSLATIONS_DEST_DIR_EXIST = $$CHECK_DIR_EXIST $$COMPILED_TRANSLATIONS_DEST
  25. MAKE_COMPILED_TRANSLATIONS_DEST_DIR = $$MAKE_DIR $$COMPILED_TRANSLATIONS_DEST
  26. COPY_COMPILED_TRANSLATIONS = $$COPY $$COMPILED_TRANSLATIONS_SOURCE $$COMPILED_TRANSLATIONS_DEST
  27.  
  28. QMAKE_POST_LINK += && $$CHECK_COMPILED_TRANSLATIONS_DEST_DIR_EXIST \
  29. ($$COPY_COMPILED_TRANSLATIONS) else \
  30. ($$MAKE_COMPILED_TRANSLATIONS_DEST_DIR && $$COPY_COMPILED_TRANSLATIONS)
  31. }
To copy to clipboard, switch view to plain text mode