Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Include a library *.pro in a unit test *.pro file
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frederick0
    wrote on last edited by Frederick0
    #1

    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.

    /root
    
    #A QT unit test project
    /root/UnitTest
    /root/UnitTest.pro
    
    #A library project
    /root/ALibrary
    /root/ALibrary/ALibrary.pro
    

    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.

    /root/UnitTest.pro
    include(../ALibrary/ALibrary.pro)
    

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved