Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Best way to resolve custom .pri filepath in subdir projects?



  • My project consists of a bunch of subdirs of varying levels:

    project
      - project.pro
      - custom.pri
      - subdir1
         - subdir1.pro
         - subdir1a
            - subdir1a.pro
         - subdir1b
            - subdir1b.pro
      - subdir2
         - subdir2.pro
         - subdir2a
            - subdir2a.pro
      - subdir3
         - subdir3.pro
    

    custom.pri is included by all of the app/lib project files and contains custom build settings used by all projects. Right now I have hard coded the path to the custom.pri. For example, in subdir1a.pro I have:

    include(../../custom.pri)
    

    in subdir3.pro I have:

    include(../custom.pri)
    

    Is there a better way to achieve the including of the custom.pri without hardcoding the relative path?



  • @btse

    It depends always what you are doing in custom.pri

    For some general things you can use .qmake.conf https://doc.qt.io/qt-5/qmake-environment-reference.html#qmakespec



  • @koahnig I'm using it for quite a lot, including resolving lib dependencies and include paths. Anyways, how would using a .qmake.conf help? I would still have to specify the path for deeply nested subdir projects, wouldn't I?



  • @btse

    Because it is read for all .pro files in sub folders.
    Best is to check with a statement of
    message("we are in .qmake.conf ") or similar that it is read. It has to be placed in the root folder of your project IIRC.
    Since it is read for all subfolders you might want to think twice what you have in there.


Log in to reply