Important: Please read the 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:

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

    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 I have:


    in I have:


    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

  • @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