Results 1 to 2 of 2

Thread: How to detect shadow building in qmake?

  1. #1
    Join Date
    Jul 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to detect shadow building in qmake?

    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 

  2. #2
    Join Date
    Jul 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to detect shadow building in qmake?

    I solved the issue by using

    Qt Code:
    1. !equals(PWD, $${OUT_PWD}) {
    2. # code when paths are not equal
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QMAKE: Building static library without -fPIC
    By rainman110 in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2012, 16:07
  2. building only qmake?
    By akos.maroy in forum Qt Tools
    Replies: 4
    Last Post: 27th November 2009, 00:58
  3. how to detect Qt3 ahd Qt4 with qmake?
    By learning_qt in forum Qt Programming
    Replies: 4
    Last Post: 19th October 2009, 05:41
  4. Building documentation with qmake
    By nurtsi in forum Installation and Deployment
    Replies: 3
    Last Post: 27th April 2008, 20:58
  5. Building a library with qmake
    By wallyqt in forum Qt Programming
    Replies: 3
    Last Post: 22nd November 2007, 14:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.