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

Including multiple .pri files similar to Makefiles



  • As I stated in a previous post, I'm not a genius with Qt's pro file. I was hoping that it worked similar to Makefile includes. For example, I'm creating a directories.pri that defines the directory locations, in the form of My_Directory = /home/usr/buildarea/ of some libraries. From there I have a top level defaults.pri that includes directories.pri and then uses the $${My_Directory} to resolve paths for libs and such. Both directories.pri and defaults.pri live on the same directory level. In a sub directory I have a file including defaults.pri, but none of the directories defined in directories.pri are resolving. In fact doing a !include(directories.pri) resolves as true. Why is my sub directory's .pro unable to resolve the other pri file. Is it searching at it's own directory level instead of where defaults.pri includes it? Can you include only one .pri file?


  • Lifetime Qt Champion

    @HunterMetcalfe

    It's a bit hard for me to understand your setup.

    Can you upload a concrete example of what you are doing?

    Regards



  • @aha_1980 As I was typing out the entire structure i figured out my issue ( an aha moment indeed). I was trying to use a directory defined in directories.pri by using $(Directory) instead of $${Directory}. I'll still show my directory so others will learn as well.

    Application Directory Structure

    • Application

    • itemdirectories.pri
    • defaults.pri
    • application
      application.pro
       *.hpp - headers
       *.cpp – sources

    directories.pri
    MY_DIR = $(TOPDIR)/library #TOPDIR is set at the environment

    defaults.pri
    include(./directories.pri)
    LIBS += -L$${MY_DIR)/lib \ #My mistake here was I had $(MY_DIR) instead of $${MY_DIR}
    INCLUDEPATH += $${MY_DIR}/inc \

    application.pro
    include(../defaults.pri)


  • Lifetime Qt Champion

    @HunterMetcalfe

    I like people getting aha moments when reading my posts :)

    Glad you figured it out and thanks for sharing.

    Regards


Log in to reply