Qt World Summit: Submit your Presentation


qmake does not read prf file located in project root directory



  • The qmake documentation [1] indicates that .prf files lookup includes the project root directory. However, it looks like it's not the case with qmake 3.1. Using strace, I confirm that the file is not read unless the path is added to QMAKEFEATURES property.

    With myfeatures.prf is inside the project root directory
    in project.pro:
    CONFIG += myfeatures
    
    $ strace qmake ../scratchpad-virtuel/ 2>&1 | grep myfeatures.prf
    stat("/home/francisg/Qt5.9.0/5.9/gcc_64/mkspecs/features/unix/myfeatures.prf", 0x7ffddc3b2f70) = -1 ENOENT (No such file or directory)
    stat("/home/francisg/Qt5.9.0/5.9/gcc_64/mkspecs/features/myfeatures.prf", 0x7ffddc3b2f70) = -1 ENOENT (No such file or directory)
    
    Setting the property:
    qmake -set QMAKEFEATURES /path/to/project
    
    $ strace qmake /path/to/project 2>&1 | grep myfeatures.prf
    stat("/path/to/project/myfeatures.prf", {st_mode=S_IFREG|0644, st_size=881, ...}) = 0
    open("/path/to/project/myfeatures.prf", O_RDONLY|O_CLOEXEC) = 3
    

    Actually, by adding the variable in .qmake.conf at the project root directory, the file is read:

    QMAKEFEATURES=$$PWD
    

    Maybe we can update the doc?

    [1] http://doc.qt.io/qt-5/qmake-advanced-usage.html


  • Lifetime Qt Champion

    Hi,

    Sounds rather like it could be a bug.

    Do you have a minimal compilable example that shows this behaviour ?

    Just in case, 5.9.1 got released last week so it might be worth checking before going further.



  • Here is a minimal example to reproduce the problem. By removing the .qmake.conf file, the message "inside myfeatures.prf" will not be written when calling qmake.

    https://github.com/giraldeau/qt-topic-81179


  • Lifetime Qt Champion

    Following QTBUG-21411, it could be a documentation issue but it's not really clear.

    In any case, one workaround could be to use a features folder in your project. Might not be ideal but should be working on all platforms.



  • @SGaist
    Yes, I am well aware this old! I have been struggling with this --- trying to put a myfeatures.prf file into same directory as my .pro file (under Linux, if it makes any difference).

    I tried putting it in the project/,pro file directory, a sub-directory named features and a sub-sub-directory named mkspecs/features. qmake does not pick up any of these. The only thing I found which does work is in the project/.pro file directory do a touch .qmake.cache. Then it does read it! Though I have no idea what any side-effects of creating this file might be for anything else.....

    UPDATE
    After cleaning up I was unable to make it work again. I now find that in addition to creating a .qmake.cache in the project/.pro folder you must put the features.prf file down in mkspecs/features/ from there. Both of these are necessary:

    project.pro
    .qmake.cache
    mkspecs/features/myfeature.prf
    

  • Moderators

    @JonB said in qmake does not read prf file located in project root directory:

    I now find that in addition to creating a .qmake.cache in the project/.pro folder

    This makes no sense. This file is created by qmake for internal purposes. Could you repeat your last attempt with this file removed and confirm this file is required?


Log in to reply