Fix qmake generating bizarre msvc /VERSION values
The msvc_nmake and msvc_vcproj generators deduced the exe/dll header version number from the VERSION variable in a "bizarre" way: VERSION=1.2.3.4567 was converted to /VERSION:1.234567. But a minor number beyond 65535 is not accepted by the linker. This fix deduces the major and minor from the major and minor of VERSION: VERSION=1.2.3.4567 leads to /VERSION:1.2. In addition, a new variable is introduced: VERSION_PE_HEADER. With this variable, legacy pro files that rely on the bizarre behavior can re-create it: VERSION=1.2.3.45 and VERSION_PE_HEADER=1.2345 lead to the old result: /VERSION:1.2345 by just taking the VERSION_PE_HEADER to overrule the new behavior. Task-number: QTBUG-44823 Change-Id: Ie093ade83290c098fe2b2a429ce5d6ed6dc750ea Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
e63752e6bb
commit
fa1b2dc4a0
@ -982,3 +982,7 @@ QMAKE_SONAME_PREFIX = @executable_path/../Frameworks
|
||||
QMAKE_SONAME_PREFIX = @loader_path/Frameworks
|
||||
QMAKE_SONAME_PREFIX = /Library/Frameworks
|
||||
#! [184]
|
||||
|
||||
#! [185]
|
||||
VERSION_PE_HEADER = 1.2
|
||||
#! [185]
|
||||
|
@ -2484,6 +2484,16 @@
|
||||
|
||||
\snippet code/doc_src_qmake-manual.pro 57
|
||||
|
||||
\section1 VERSION_PE_HEADER
|
||||
|
||||
Windows only. Specifies the version number, that the Windows linker
|
||||
puts into the header of the .exe or .dll file via the /VERSION option.
|
||||
Only a major and minor version may be specified.
|
||||
If VERSION_PE_HEADER is not set, it falls back to
|
||||
the major and minor version from \l{VERSION} (if set).
|
||||
|
||||
\snippet code/doc_src_qmake-manual.pro 185
|
||||
|
||||
\section1 VER_MAJ
|
||||
|
||||
Specifies the major version number of the library if the
|
||||
|
@ -354,14 +354,18 @@ void NmakeMakefileGenerator::init()
|
||||
project->values("QMAKE_LFLAGS").append(QString("/DEF:") + escapeFilePath(defFileName));
|
||||
}
|
||||
|
||||
if(!project->values("VERSION").isEmpty()) {
|
||||
ProString version = project->values("VERSION")[0];
|
||||
int firstDot = version.indexOf(".");
|
||||
QString major = version.left(firstDot).toQString();
|
||||
QString minor = version.right(version.length() - firstDot - 1).toQString();
|
||||
minor.replace(".", "");
|
||||
project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor);
|
||||
// set /VERSION for EXE/DLL header
|
||||
ProString major_minor = project->first("VERSION_PE_HEADER");
|
||||
if (major_minor.isEmpty()) {
|
||||
ProString version = project->first("VERSION");
|
||||
if (!version.isEmpty()) {
|
||||
int firstDot = version.indexOf(".");
|
||||
int secondDot = version.indexOf(".", firstDot + 1);
|
||||
major_minor = version.left(secondDot);
|
||||
}
|
||||
}
|
||||
if (!major_minor.isEmpty())
|
||||
project->values("QMAKE_LFLAGS").append("/VERSION:" + major_minor);
|
||||
|
||||
if (project->isEmpty("QMAKE_LINK_O_FLAG"))
|
||||
project->values("QMAKE_LINK_O_FLAG").append("/OUT:");
|
||||
|
@ -787,14 +787,18 @@ void VcprojGenerator::init()
|
||||
|
||||
processVars();
|
||||
|
||||
if(!project->values("VERSION").isEmpty()) {
|
||||
QString version = project->values("VERSION")[0].toQString();
|
||||
int firstDot = version.indexOf(".");
|
||||
QString major = version.left(firstDot);
|
||||
QString minor = version.right(version.length() - firstDot - 1);
|
||||
minor.replace(QRegExp("\\."), "");
|
||||
project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor);
|
||||
// set /VERSION for EXE/DLL header
|
||||
ProString major_minor = project->first("VERSION_PE_HEADER");
|
||||
if (major_minor.isEmpty()) {
|
||||
ProString version = project->first("VERSION");
|
||||
if (!version.isEmpty()) {
|
||||
int firstDot = version.indexOf(".");
|
||||
int secondDot = version.indexOf(".", firstDot + 1);
|
||||
major_minor = version.left(secondDot);
|
||||
}
|
||||
}
|
||||
if (!major_minor.isEmpty())
|
||||
project->values("QMAKE_LFLAGS").append("/VERSION:" + major_minor);
|
||||
|
||||
MakefileGenerator::init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user