summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/msvc_vcproj.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-07-17 15:11:07 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-07-31 10:13:31 +0000
commit8cea3ec8ce7f4110e849b53e3c97b690a8899dd9 (patch)
treeced62839aa69423773ea860dcb736e9a20930755 /qmake/generators/win32/msvc_vcproj.cpp
parent3ed22c5efe538204a496d30b881f3999c020caa7 (diff)
qmake: Harden logic for handling the -o option
We now treat -o foo/bar/baz as a request to generate the output in the foo/bar directory with baz as the output name, or if foo/bar/baz is already a directory, in the foo/bar/baz directory with the default output name. We take care to handle generator specific directory structures, so that the project directory does not get merged into OUT_PWD. This is done in runQmake(), before parsing the project file, so that OUT_PWD will be correct during project parsing. The individual generators are then passed the filename relative to the final output directory. Each generator now also makes sure to add the right project suffix to the output file, so -o foo will result in foo.pro or foo.vcproj, instead of just foo. Task-number: QTBUG-44408 Change-Id: I26990cec0c0458bee2b88dbb86322617a85f54b5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp')
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 24d1657552..b812e3a326 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1617,20 +1617,15 @@ QString VcprojGenerator::replaceExtraCompilerVariables(
bool VcprojGenerator::openOutput(QFile &file, const QString &/*build*/) const
{
- QString outdir;
- if(!file.fileName().isEmpty()) {
- QFileInfo fi(fileInfo(file.fileName()));
- if(fi.isDir())
- outdir = file.fileName() + QDir::separator();
- }
- if(!outdir.isEmpty() || file.fileName().isEmpty()) {
- ProString ext = project->first("VCPROJ_EXTENSION");
- if(project->first("TEMPLATE") == "vcsubdirs")
- ext = project->first("VCSOLUTION_EXTENSION");
- ProString outputName = project->first("TARGET");
- if (!project->first("MAKEFILE").isEmpty())
- outputName = project->first("MAKEFILE");
- file.setFileName(outdir + outputName + ext);
+ ProString fileName = file.fileName();
+ ProString extension = project->first("TEMPLATE") == "vcsubdirs"
+ ? project->first("VCSOLUTION_EXTENSION") : project->first("VCPROJ_EXTENSION");
+ if (!fileName.endsWith(extension)) {
+ if (fileName.isEmpty()) {
+ fileName = !project->first("MAKEFILE").isEmpty()
+ ? project->first("MAKEFILE") : project->first("TARGET");
+ }
+ file.setFileName(fileName + extension);
}
return Win32MakefileGenerator::openOutput(file, QString());
}