Feature Request: Support add_link_options(LINKER:/MANIFEST:EMBED) for MSVC compiler
As far as I can tell with the limited testing I've done, it's sufficient to change cmcmd.cxx line 2292 from
} else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0 ||
cmSystemTools::Strucmp(arg->c_str(), "-MANIFEST:NO") == 0) {
this->LinkGeneratesManifest = false;
to
} else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0 ||
cmSystemTools::Strucmp(arg->c_str(), "-MANIFEST:NO") == 0 ||
cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:EMBED") == 0 ||
cmSystemTools::Strucmp(arg->c_str(), "-MANIFEST:EMBED") == 0) {
this->LinkGeneratesManifest = false;
This change prevents each dll or exe generated by the project from also having an associated .manifest generated next to it on the file system. Instead, these .manifest files are embedded directly into the artifact by the linker.
For corporate environments with restrictive anti-viruses, reducing the number of individual files that are written to disk can provide a disproportionate speedup of build times. In my case, the number of files generated by the build being reduced by /MANIFEST:EMBED saved about 5% total build time because of A/V interference. Mileage may vary, of course.
The same cmVSLink
class in cmcmd.cxx contains logic for allowing user-specified manifests to be provided and merged into the linker generated manifest file. This should still work as-is.
Without the change described above, adding add_link_options(LINKER:/MANIFEST:EMBED) causes build errors because the options provided to mt.exe aren't right, and it fails the build.
Documentation for the /MANIFEST flags are found here: https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest