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

qmake vcxproj generator doesn't add extra compiler input files to project

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.11.2
    • 5.9.2
    • Build tools: qmake
    • None
    • Windows
    • f2668c6b43a80a83ebdd46407a01af8a0dc6285f

    Description

      When using qmake to generate a vcxproj file, and the .pro file uses a custom compiler (as specified in QMAKE_EXTRA_COMPILERS), input files used by that extra compiler are not added to the project, and of course neither are commands associated with them.

      Explicitly adding them to SOURCES works around that (but breaks makefile generation).

      The problem appears to be in VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) in msbuild_objectmodel.cpp . It sets up

      VCProject tempProj;
      tempProj.SingleProjects += tool;

      and later iterates over tempProj.ExtraCompilers - but it never actually initializes tempProj.ExtraCompilers, they are always empty. Adding these lines (stolen from VCProjectWriter::write in msvc_objectmodel.cpp) seems to fix it:

      QSet<QString> extraCompilersInProject;
      for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) {
        const QString &compilerName = tool.ExtraCompilersFiles.at.Name;
        if (!extraCompilersInProject.contains(compilerName)) {
          extraCompilersInProject += compilerName;
          tempProj.ExtraCompilers += compilerName;
        }
      }

       

      The problem is reproducible in a single-configuration build, but not in multi-configuration one. Test case:

      ## test.src
      int main() { return 0; }
      
      ## test.pro
      
      TEMPLATE = app
      TARGET = test
      QT -= core gui
      win32:CONFIG += console
      
      # Forcing single-config build triggers the bug
      CONFIG *= debug
      CONFIG -= debug_and_release
      
      SRCFILES = test.src
      
      srctocpp.name = "SRC to CPP"
      srctocpp.input = SRCFILES
      srctocpp.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.cpp
      srctocpp.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
      srctocpp.variable_out = GENERATED_FILES
      QMAKE_EXTRA_COMPILERS += srctocpp
      
      # Without this, test.src doesn't get added to the generated vcxproj project
      # file, and then test.cpp doesn't get generated.
      # But with this, the generated makefile attemps to apply C++ compiler rules
      # to test.src, in addition to test.cpp
      # SOURCES += test.src
      
      ## command line
      qmake -spec win32-msvc -tp vc test.pro
      

       

      Attachments

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

        Activity

          People

            jbornema Joerg Bornemann
            itandetnik Igor Tanditnik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes