Questions about qmake and the project file



  • Here's the first few lines of my project's .pro file:
    @######################################################################

    Automatically generated by qmake (2.01a) Mon Mar 28 17:09:16 2011

    ######################################################################

    TEMPLATE = app
    TARGET =
    DEPENDPATH += . headers src
    INCLUDEPATH += . headers

    APP_QML_FILES.files = DemodShaperFilter.qml
    APP_QML_FILES.path = Contents/MacOS
    QMAKE_BUNDLE_DATA += APP_QML_FILES
    @

    A couple of questions:

    1. I know that this file is automatically generated by qmake (after all, it says so in the comment!), but...qmake seems "smart" enough to prevent my modifications from being deleted. At least, running qmake doesn't seem to wipe them out. Can someone confirm this, and perhaps explain how this happens?

    2. My project uses several data files that need to be co-resident with the application binary. It would be really cool if I could have those automatically moved into the same folder that the .qml file in the example above goes into. How might I make this happen?

    Thanks.



  • The .pro file is generated by following command:
    @
    qmake -project
    @
    Run qmake -h to get more help.

    Then the created .pro file shoule be edited manually or through IDE such as QtCreator.



  • Regarding #1:
    If you call

    @qmake -project@

    your .pro file is wiped out and replaced by the newly generated one. Be careful!

    If you just call

    @qmake@

    then qmake just reads the .pro file and generates Makefile (and probably Makefile.Debug and Makefile.Release) for you.

    Regarding #2:
    You can add your own target in the .pro file, just replace APP_QML_FILES with something you like and adjust the file list.



  • Thanks, Volker. So: is a symbol like APP_QML_FILES something I can just make on-the-fly, or is this a reserved keyword in qmake?

    Can I just duplicate those lines rather than replace them? Like APP_COEFF_FILES?



  • That's something you can make on the fly. You must make sure to choose a name that's not used elsewhere, so using an application or organization specific prefix for the name - like MYCOMP_ - will be a good idea.



  • Good point. So, when does this extra stuff get processed: when qmake is run, or when you push "build" in Creator?



  • When you run build in Creator - or call make on the command line, which is basically the same that Creator does for you :)



  • OK, so it's truly part of the make process then. Excellent. I'll go try it now, and come back to ask more questions when I screw it up. Thanks!



  • Is there a way to put multiple files on a single line? Like:

    @APP_COEFF_FILES.files = coeffdemodshaper.txt coeffmodnyquist.txt
    APP_COEFF_FILES.path = Contents/MacOS

    QMAKE_BUNDLE_DATA += APP_COEFF_FILES
    @

    I've tried it with and without a comma, and both give me a build error:

    bq. make: *** No rule to make target coeffmodnyquist.txt', needed bysimulatorGUI.app/Contents/MacOS/coeffmodnyquist.txt'. Stop.

    Thanks.

    EDIT:

    OK, I can see why this wouldn't work. So, can I specify a subdirectory's entire contents as part of the bundle?



  • Yes you can. Just put the path of the subdir into the .files section. That will copy that directory and all its contents and subdirectories into the app bundle.



  • Oh, that's pretty slick. Thanks, Volker.


Log in to reply
 

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