Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76097

qmake incorrectly uses SOURCES from sibling directories outside the project root

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.12.3
    • Fix Version/s: 5.14.0 Alpha
    • Component/s: Build tools: qmake
    • Labels:
      None
    • Environment:
      Arch Linux
      QMake version 3.1
      Using Qt version 5.12.3 in /usr/lib
      GNU Make 4.2.1
      g++ (GCC) 8.3.0
    • Commits:
      57f38bc49d43140f3b04e625a47eb1e6de8d2ae3 (qt/qtbase/dev)

      Description

      The situation:

        mylib/       # This dir should be irrelevant, but isn't!

          mylib.cpp  # This file is added to the build!

        myapp/

          myapp.pro

          mylib/

            mylib.pri

            mylib.cpp

            bar.cpp

          build/     # Doing my builds in here

      From myapp.pro, I'm including mylib.pri:

        include(mylib/mylib.pri)

      From mylib.pri, I'm adding mylib's sources to the build:

        SOURCES += $$PWD/mylib.cpp $$PWD/bar.cpp

       

      Then I'm running qmake, inside myapp/build:

        rm -rf build && mkdir build && (cd build && qmake ..)

      Inspecting the generated Makefile reveals:

        SOURCES = ../../mylib/mylib.cpp
                  ../mylib/bar.cpp
                  ../myapp.cpp

      That's one ../ too many for mylib.cpp! But bar.cpp, which exists only in myapp/mylib/ but not in the top-level copy of mylib/, is resolved correctly.

       

      Clues:

      • message($$SOURCES) shows the correct absolute paths, so somehow these are turned into incorrect relative paths at some later stage.
      • If I just put the SOURCES of mylib directly into myapp.pro rather than using include(), the problem goes away.
      • If I rename the top-level mylib to something else, the problem goes away.
      • If I put the build/ directory as a sibling to myapp/, the problem goes away.
      • If I put the build/ directory as a sub-sub-directory like myapp/build/build, the problem goes away.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            kkohne Kai Köhne
            Reporter:
            thomastc Thomas ten Cate
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes