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. [SOLVED] How can I test whether a .pri file has already been included
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How can I test whether a .pri file has already been included

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 6.9k 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.
  • D Offline
    D Offline
    dusktreader
    wrote on last edited by
    #1

    I have multiple subfolders of a project. Each of these subfolders contains a .pri file describing what files need to be included. There is some cross-referencing when a subfolder needs a component from another. A simple and silly description of this problem is as follows:

    in /root/sub0/sub0.pri:
    include( /root/sub1/sub1.pri )

    in /root/sub1/sub1.pri:
    include( /root/sub0/sub0.pri )

    in /root/root.pri
    include( /root/sub0/sub0.pri )
    include( /root/sub1/sub1.pri )

    When I compile this after running qmake, I get problems with:

    "overriding commands for target ------"

    and warnings about multiple definitions.

    Is there a way in a qmake project file to test if a .pri file has already been included somewhere else??

    “Machines take me by surprise with great frequency.” -- Alan Mathison Turing

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      You can use same approach as in c/c++ headers. Defines. Just test for define and if not defined then define it and do stuff.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dusktreader
        wrote on last edited by
        #3

        what is the syntax for that in a .pri file?

        “Machines take me by surprise with great frequency.” -- Alan Mathison Turing

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          I think "isEmpty":http://developer.qt.nokia.com/doc/qt-4.7/qmake-function-reference.html#id-141c6ec1-7a4a-42f2-bd82-1e8a7ea79bdb will help you

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dusktreader
            wrote on last edited by
            #5

            Thank you Denis. I took your advice and expanded it a bit. Here's the template that I used for protecting my .pri files from multiple inclusion:

            @
            !contains( included_modules, $$PWD ) {
            included_modules += $$PWD
            message( "Including $$PWD" )

            .pri body

            HEADERS, SOURCES, QT *=, include(), etc...

            } else {
            message( "Skipping $$PWD: already included" )
            }
            @

            Thanks for the help

            “Machines take me by surprise with great frequency.” -- Alan Mathison Turing

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

              You are welcome. Please mark thread as [solved].

              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