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

Precompiled headers don't work in Visual Studio when building in a shadow build folder

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.3.2
    • Build tools: qmake
    • None
    • Windows 7

    Description

      I created a pre-compiled header for my project using the following guide: http://doc.qt.io/qt-5/qmake-precompiledheaders.html such that my .pro file looks like:

      CONFIG += precompile_header
      SOURCES += $$PWD/*.cpp
      PRECOMPILED_HEADER = precompiled.h

      Based on advice from: http://stackoverflow.com/a/13711532/2558027 I also added:

      win32-msvc*

      { PRECOMPILED_SOURCE = precompiled.cpp }

      When using this project with Qt Creator I haven't had any problems. However I then started trying to use it with Visual Studio, I created the project files in a shadow build folder with:

      cd buildfolder
      qmake.exe ..\sourcefolder\projects.pro -r -tp vc -spec win32-msvc2013

      And opened the resulting .sln file in Visual Studio. However the project not contained two copies of precompiled.cpp, one in my source folder with /Yu set and one in my build folder with /Yc set. Obviously when I try to compile I get MSB8027 followed by C1083 since the file in my build folder doesn't actually exist. Removing the PRECOMPILED_SOURCE from the .pro file gets rid of the ghost file in the build folder but that also means that the pre-compiled header doesn't get built and so all files with /Yu set fail to compile. Setting it to PRECOMPILED_SOURCE = $$PWD/precompiled.cpp doesn't seem to have an effect either.

      Attachments

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

        Activity

          People

            jbornema Joerg Bornemann
            sjdowling Samuel Dowling
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes