Important: Please read the Qt Code of Conduct -

Include a library *.pro in a unit test *.pro file

  • I am writing a library for an application and I would like to include it in my unit test project.

    I have the following project structure.

    #A QT unit test project
    #A library project

    What I would like to do is include the library project directly into the test project so I can add/modify/delete classes in the library, but still be able to re-run my unit test.

    I have been reading through the QMake manual and noticed that I can include another .pro file in my project by using include

    Because of this i updated the unit test pro to include the library pro file.


    I now see the library .pro file and directory in my unit test project. However, every time I run qmake I notice that it cannot locate any of the files in my library. I tried the obvious of updating the INCLUEPATH && DEPENDPATH in my test pro to include the library paths, but I am still receiving a warning and the build fails that it cannot locate the files.

    INCLUDEPATH += ../ALibrary
    DEPENDPATH += ../ALibrary

    Any ideas on what I am missing?

  • Lifetime Qt Champion


    You should rather have a .pri file dedicated for that. .pro files are usually used to setup everything for building your application/library project. A .pri file is rather a file what will contain the paths + link command for your custom library.

    I wouldn't recommend re-building the code of your library within each test. You will miss things like setting symbol exports properly for the Windows platform and also have longer build time which is also not something one wants.

    Hope it helps

Log in to reply