Search code examples
versioningqmake

Versioning absolute paths in qt .pro files


lets say i have a qt project file (*.pro) and related files under a versioning system (git). The project is multiplatform and developing is performed on a lot of different ones as well. Developmers are both progrmmers and not programmers (matematicians, ecc) so i'd like to keep things as easier as possible for the person who cloned it (eg: avoid env variables).

The project is dependent on other projects whose are in an non-standard folder in the developer platform. So i need them to edit the project file INCLUDEPATH += "absolute-path-to-external-stuff"

Problem is i'd like to put this single line in a file to be included in the .gitignore (remove it from versioning once uploaded) so that one can freely edit it without editing others when pushing to repo.

Should i use .pri files (and how? it seems they only are ok in subdirectories, cant find a reference) or is there a better pattern?


Solution

  • You can use a .pri file for that — a .pri is just a file that gets include()d by a .pro file.

    • Create a file in the project root called config.pri, containing the INCLUDEPATH addition
    • Add include(config.pri) to your main project file
    • Add the config.pri to your .gitignore

    In the long run, you might consider using pkg-config to manage dependencies, since it integrates nicely with qmake.