summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index a23f34a..22381bc 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -2138,6 +2138,7 @@ class cmVSLink
int Type;
bool Verbose;
bool Incremental = false;
+ bool LinkEmbedsManifest = true;
bool LinkGeneratesManifest = true;
std::vector<std::string> LinkCommand;
std::vector<std::string> UserManifests;
@@ -2292,6 +2293,12 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
} else if (cmHasLiteralPrefix(*arg, "--mt=")) {
this->MtPath = arg->substr(5);
++arg;
+ } else if (cmHasLiteralPrefix(*arg, "--msvc-ver=")) {
+ unsigned long msvc_ver = 0;
+ if (cmStrToULong(arg->c_str() + 11, &msvc_ver)) {
+ this->LinkEmbedsManifest = msvc_ver > 1600;
+ }
+ ++arg;
} else {
std::cerr << "unknown argument '" << *arg << "'\n";
return false;
@@ -2341,11 +2348,13 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
// pass it to the link command.
this->ManifestFileRC = intDir + "/manifest.rc";
this->ManifestFileRes = intDir + "/manifest.res";
+ }
- if (this->LinkGeneratesManifest) {
- this->LinkCommand.emplace_back("/MANIFEST");
- this->LinkCommand.push_back("/MANIFESTFILE:" + this->LinkerManifestFile);
- }
+ if (this->LinkGeneratesManifest &&
+ (this->Incremental || !this->LinkEmbedsManifest)) {
+ this->LinkCommand.emplace_back("/MANIFEST");
+ this->LinkCommand.emplace_back("/MANIFESTFILE:" +
+ this->LinkerManifestFile);
}
return true;
@@ -2479,6 +2488,24 @@ int cmVSLink::LinkIncremental()
int cmVSLink::LinkNonIncremental()
{
+ if (!this->LinkEmbedsManifest) {
+ // Run the link command (possibly generates intermediate manifest).
+ if (!RunCommand("LINK", this->LinkCommand, this->Verbose,
+ FORMAT_DECIMAL)) {
+ return -1;
+ }
+
+ // If we have no manifest files we are done.
+ if (!this->LinkGeneratesManifest && this->UserManifests.empty()) {
+ return 0;
+ }
+
+ // Run the manifest tool to embed the final manifest in the binary.
+ std::string mtOut = "/outputresource:" + this->TargetFile +
+ (this->Type == 1 ? ";#1" : ";#2");
+ return this->RunMT(mtOut, false);
+ }
+
// The MSVC link tool expects 'rc' to be in the PATH if it needs to embed
// manifests, but the user might explicitly set 'CMAKE_RC_COMPILER' instead.
// Add its location as a fallback at the end of PATH.