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

qmake incorrectly uses SOURCES from sibling directories outside the project root

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.14.0 Alpha
    • 5.12.3
    • Build tools: qmake
    • None
    • 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
    • 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

        1. repro.tar.gz
          0.4 kB
          Thomas ten Cate
        For Gerrit Dashboard: QTBUG-76097
        # Subject Branch Project Status CR V

        Activity

          People

            kkohne Kai Köhne
            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