Results 1 to 2 of 2

Thread: Copying OTHER_FILES into build directory

  1. #1
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Copying OTHER_FILES into build directory

    Hello all,

    I'm trying to get qmake to run qhelpgenerator and qcollectiongenerator for me at build time, and that part works - however, the problem I'm having is that I can't seem to get the contents of OTHER_FILES to be copied into the build directory during build. I tried adding a manual copy command, but the PWD variable always includes the build directory (not where the project file is located, as per the docs), and OUT_PWD is always blank. Take the following example (which is a .pri file, included from a subdirectory):

    Qt Code:
    1. # load correct help libraries for specific OSes
    2. # and copy correct files to correct locations during build
    3.  
    4. help_copy.target = dox
    5. help_copy.commands = @echo "Building Help Collections";
    6.  
    7.  
    8. win32 {
    9. CONFIG += help
    10. }
    11.  
    12. macx {
    13. LIBS += -framework QtHelp
    14. help_copy.commands += echo "cp $$(PWD)/docs/* $$(OUT_PWD)/";
    15. help_copy.commands += $$[QT_INSTALL_BINS]/qhelpgenerator docs.qhp -o docs.qch;
    16. help_copy.commands += $$[QT_INSTALL_BINS]/qcollectiongenerator docs.qhcp -o docs.qhc;
    17. }
    18.  
    19. QMAKE_EXTRA_TARGETS += help_copy
    20. POST_TARGETDEPS += dox
    21.  
    22. OTHER_FILES += \
    23. docs/foodoc.html \
    24. docs/foo-ovr.png \
    25. docs/docs.qhp \
    26. docs/docs.qhcp \
    27. docs/docs.qhc \
    28. docs/docs.qch
    29.  
    30. HEADERS += \
    31. docs/helpwindow.h \
    32. docs/helpbrowser.h
    33.  
    34. SOURCES += \
    35. docs/helpwindow.cpp \
    36. docs/helpbrowser.cpp
    37.  
    38. FORMS += \
    39. docs/helpwindow.ui
    To copy to clipboard, switch view to plain text mode 

    The build output produces the following:

    Qt Code:
    1. Building Help Collections
    2. cp /Users/user/Source/Software/Foo/trunk/Foo-build-desktop-Desktop_Qt_4_8_0_RC_for_GCC__Qt_SDK__Debug/gui/docs/* /
    3. Could not open /Users/user/Source/Software/Foo/trunk/Foo-build-desktop-Desktop_Qt_4_8_0_RC_for_GCC__Qt_SDK__Debug/gui/docs.qhp.
    4. Could not open /Users/user/Source/Software/Foo/trunk/Foo-build-desktop-Desktop_Qt_4_8_0_RC_for_GCC__Qt_SDK__Debug/gui/docs.qhcp.
    5. make[1]: *** [dox] Error 255
    To copy to clipboard, switch view to plain text mode 

    Where the .pro file is located in /Users/user/Source/Software/Foo/trunk/Foo/, the .pri file is located in /Users/user/Source/Software/Foo/trunk/Foo/docs/, and the build directory is /Users/user/Source/Software/Foo/trunk/Foo-build-desktop-Desktop_Qt_4_8_0_RC_for_GCC__Qt_SDK__Debug/

    Any advice on what I've done wrong here? Is there a an easier way than a manual copy command to get OTHER_FILES into the build directory?

    Thanks!

  2. #2
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Copying OTHER_FILES into build directory

    Following-up, I found the problem:

    Qt Code:
    1. $$(PWD)
    To copy to clipboard, switch view to plain text mode 

    is incorrect - that looks for an environment variable. The correct usage was:

    Qt Code:
    1. $$PWD
    To copy to clipboard, switch view to plain text mode 

    Of course, much more than that was required. Here's, ultimately, how I built my help automatically, and placed it in the right locations:

    docs.pri:

    Qt Code:
    1. # load correct help libraries for specific OSes
    2. # and copy correct files to correct locations during build
    3.  
    4.  
    5. win32 {
    6.  
    7. CONFIG += help
    8.  
    9. CONFIG(debug, debug|release) {
    10. DDIR = $$OUT_PWD/debug/docs
    11. }
    12. CONFIG(release, debug|release) {
    13. DDIR = $$OUT_PWD/release/docs
    14. }
    15. DDIR ~= s,/,\\,g
    16. }
    17.  
    18. macx {
    19. LIBS += -framework QtHelp
    20.  
    21. DDIR = $$OUT_PWD/Graffik.app/Contents/MacOS/docs
    22. }
    23.  
    24. defineTest(copyHelpFiles) {
    25. files = $$1
    26.  
    27.  
    28. for(FILE, files) {
    29. FILE ~= s,docs/,,
    30. FILE = $$PWD/$$FILE
    31. MYFILECOPY += @echo "Copying $$FILE" $$escape_expand(\\n\\t)
    32. # Replace slashes in paths with backslashes for Windows
    33. win32:FILE ~= s,/,\\,g
    34.  
    35.  
    36. MYFILECOPY += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
    37. }
    38. export(MYFILECOPY)
    39. }
    40.  
    41.  
    42. OTHER_FILES += \
    43. docs/docs.html \
    44. docs/file1.png \
    45. docs/file2.png \
    46. docs/docs.qhp \
    47. docs/docs.qhcp
    48.  
    49. HEADERS += \
    50. docs/helpwindow.h \
    51. docs/helpbrowser.h
    52.  
    53. SOURCES += \
    54. docs/helpwindow.cpp \
    55. docs/helpbrowser.cpp
    56.  
    57. FORMS += \
    58. docs/helpwindow.ui
    59.  
    60.  
    61. copyHelpFiles($$OTHER_FILES)
    62.  
    63. help_copy.target = dox
    64. help_copy.commands = @echo "Building Help Files in $$DDIR" $$escape_expand(\\n\\t)
    65.  
    66. win32 {
    67.  
    68. # exists does not like backslashes
    69. EDIR = $$DDIR
    70. EDIR ~= s,\\,/,g
    71.  
    72. !exists($$EDIR) {
    73. help_copy.commands += @echo "Creating Docs Directory: $$DDIR" $$escape_expand(\\n\\t)
    74. help_copy.commands += md $$DDIR $$escape_expand(\\n\\t)
    75. }
    76.  
    77. help_copy.commands += $$MYFILECOPY
    78. help_copy.commands += @echo "Running qhelpgenerator" $$escape_expand(\\n\\t)
    79. help_copy.commands += $$[QT_INSTALL_BINS]\\qhelpgenerator $$DDIR\\docs.qhp -o $$DDIR\\docs.qch $$escape_expand(\\n\\t)
    80. help_copy.commands += @echo "Running qcollectiongenerator" $$escape_expand(\\n\\t)
    81. help_copy.commands += $$[QT_INSTALL_BINS]\\qcollectiongenerator $$DDIR\\docs.qhcp -o $$DDIR\\docs.qhc $$escape_expand(\\n\\t)
    82. }
    83.  
    84. macx {
    85.  
    86. !exists($$DDIR) {
    87. help_copy.commands += @echo "Creating Docs Directory: $$DDIR" $$escape_expand(\\n\\t)
    88. help_copy.commands += mkdir -p $$DDIR $$escape_expand(\\n\\t)
    89. }
    90.  
    91. help_copy.commands += $$MYFILECOPY
    92. help_copy.commands += @echo "Running qhelpgenerator" $$escape_expand(\\n\\t)
    93. help_copy.commands += $$[QT_INSTALL_BINS]/qhelpgenerator $$DDIR/docs.qhp -o $$DDIR/docs.qch $$escape_expand(\\n\\t)
    94. help_copy.commands += @echo "Running qcollectiongenerator" $$escape_expand(\\n\\t)
    95. help_copy.commands += $$[QT_INSTALL_BINS]/qcollectiongenerator $$DDIR/docs.qhcp -o $$DDIR/docs.qhc $$escape_expand(\\n\\t)
    96. }
    97.  
    98. QMAKE_EXTRA_TARGETS += help_copy
    99. POST_TARGETDEPS += dox
    To copy to clipboard, switch view to plain text mode 

    A little messy, but good enough for the task at-hand.

Similar Threads

  1. QMake problem when using INSTALL and a shadow build directory
    By superpacko in forum Qt Tools
    Replies: 0
    Last Post: 6th September 2011, 15:43
  2. Replies: 0
    Last Post: 10th March 2011, 13:55
  3. how to specify the build directory
    By kamlmish in forum Newbie
    Replies: 1
    Last Post: 27th January 2011, 06:34
  4. Qt Creator Help running git build in custom directory
    By tbscope in forum Qt Tools
    Replies: 2
    Last Post: 16th August 2010, 05:29
  5. QT 4.5.1 failed to build with gtk/gtk.h: No such file or directory
    By doggrant in forum Installation and Deployment
    Replies: 5
    Last Post: 28th August 2009, 15:55

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.