Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.2
-
None
-
-
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
For Gerrit Dashboard: QTBUG-69769 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
236216,4 | qmake vcxproj generator: Fix extra compilers for single configs | 5.11 | qt/qtbase | Status: MERGED | +2 | 0 |