[resolved] getting qmake to copy some data files for me



  • A few months ago, I asked a question "in this thread":http://developer.qt.nokia.com/forums/viewthread/7487/ about getting the build process to move data files from the source folder structure into the build folder structure. It worked fine on my Mac, but this weekend I began trying to port to a Windows XP machine. The build of the binary works, but not the moving of the data files.

    The reason for this is obvious, as the pathname is different on the XP system (here's part of my .pro file):

    @APP_COEFF_FILES.files = coeffs
    APP_COEFF_FILES.path = Contents/MacOS

    QMAKE_BUNDLE_DATA += APP_COEFF_FILES

    APP_DATA_FILES.files = data
    APP_DATA_FILES.path = Contents/MacOS

    QMAKE_BUNDLE_DATA += APP_DATA_FILES
    @

    So, I guess the question is, can I make this conditional on the system the build is running on? It would be nice if I could just drag the entire project, .pro file and all, from the Mac to the XP.

    Thanks...



  • According to the docs, QMAKE_BUNDLE_DATA is only used on the Mac. I didn't try if it works at all on other platforms.

    For specifying different paths, you can put that into scopes of course:

    @
    macx: {
    APP_COEFF_FILES.files = coeffs
    APP_COEFF_FILES.path = Contents/MacOS
     
    QMAKE_BUNDLE_DATA += APP_COEFF_FILES
     
    APP_DATA_FILES.files = data
    APP_DATA_FILES.path = Contents/MacOS
     
    QMAKE_BUNDLE_DATA += APP_DATA_FILES
    }

    win32: {
    APP_COEFF_FILES.files = coeffs
    APP_COEFF_FILES.path = abc
     
    QMAKE_BUNDLE_DATA += APP_COEFF_FILES
     
    APP_DATA_FILES.files = data
    APP_DATA_FILES.path = def
     
    QMAKE_BUNDLE_DATA += APP_DATA_FILES
    }
    @

    But again, I don't know whether that QMAKE_BUNDLE_DATA works at all.



  • Thanks, Volker...I'll give that a try later today, just for experimentation. After looking at this a bit more, though, I'm a little surprised that it didn't work. Why didn't the build process just create the (Mac-named) directories on the XP?

    And, is there any documentation on the language used in the .pro file? I didn't see anything on the main docs page.



  • As the docs state, that whole QMAKE_BUNDLE_DATA thingie works on the Mac only. I wouldn't expect it to work on any other platform.

    But you can write a script that copies everything into the right place, then add
    add QMAKE_POST_LINK=/path/to/your/script to the .pro file. This will call your script every time your application is built (after the link step).



  • Where are the docs for the .pro file? I couldn't find it on the main page. I found a copy script that takes parameters for the source and destination; now I just have to figure out how to pass it that information (without hard-coding it, preferably).



  • Find the docs "here":/doc/qt-4.7/qmake-manual.html and here the "variable reference":/doc/qt-4.7/qmake-variable-reference.html

    I, for example, have this in my .pro:

    @
    QMAKE_POST_LINK = ./OSX-lib-and-framework-paths.sh "$${TARGET}.app"
    @



  • Wow...that's quite a list of variables.

    In your example above, what is the syntax for the stuff in the quotes? I gather that you're forming a parameter for a script, but...what does the stuff mean? Feel free to point me to a document if one exists.

    Also, it appears that I could obviate this problem by choosing a different destination for the executable with the TARGET variable. True? Good idea/bad idea? I was thinking I could put it in the same directory as my .pro file and other stuff.



  • That's quite simple: $${XYZ} will be replaced by the contents of variable XYZ. It can be any of the predefined variables/constants of qmake or a self defined variable. I've added the quotes because my target can contain spaces and the script would interpret it as two arguments in that case. On the shell command line you would call it like this:

    @
    ./OSX-lib-and-framework-paths.sh "My Application.app"
    @

    The TARGET variable contains the base name of your final binaray. The complete file name depends on the target type as well as the operating system and is "calculated" for the respective uses. For example:

    • application on Windows: target.exe
    • static lib on Windows: target.lib
    • dynamic lib on Windows: target.dll
    • application on OS X: target.app
    • static lib on OS X: target.a
    • dynamic lib on OS X: target.dylib
    • application on Linux: target (no suffix)
    • static lib on Linux: target.a
    • dynamic lib on Linux: target.so

    The TARGET variable does not contain the path to the final binary. You should be able to construct that together with the DESTDIR variable, though.

    General info on the variable voodoo can be found in the "variable documentation":http://developer.qt.nokia.com/doc/qt-4.7/qmake-advanced-usage.html of the qmake manual. In general, it's a good idea to read that from the very beginning to the end :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.