MSVC: Run manifest tool with llvm-mt compatible arguments

Default use of `llvm-mt` was disabled by commit 73d0d4e4b5 (BinUtils:
Avoid llvm-mt because it is missing 'mt' features we use, 2022-03-08,
v3.23.0-rc3~7^2).  However, it can still be specified explicitly by the
user.  Due to limitations of LLVM's command line option parser, llvm-mt
does not support arbitrary manifest files following a single switch.

Issue: #23305
This commit is contained in:
ur4t 2023-08-11 07:05:50 +08:00 committed by Brad King
parent e70749e0d6
commit 3c0f701990
2 changed files with 6 additions and 3 deletions

View File

@ -82,7 +82,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")
set(_CMAKE_NM_NAMES "llvm-nm" "nm")
list(PREPEND _CMAKE_AR_NAMES "llvm-lib")
# llvm-mt does not support all flags we need in vs_link_exe
# llvm-mt is not ready to be used as a replacement for mt.exe
# list(PREPEND _CMAKE_MT_NAMES "llvm-mt")
list(PREPEND _CMAKE_LINKER_NAMES "lld-link")
list(APPEND _CMAKE_TOOL_VARS NM)

View File

@ -2539,14 +2539,17 @@ int cmVSLink::RunMT(std::string const& out, bool notify)
std::vector<std::string> mtCommand;
mtCommand.push_back(this->MtPath.empty() ? "mt" : this->MtPath);
mtCommand.emplace_back("/nologo");
mtCommand.emplace_back("/manifest");
// add the linker generated manifest if the file exists.
if (this->LinkGeneratesManifest &&
cmSystemTools::FileExists(this->LinkerManifestFile)) {
mtCommand.emplace_back("/manifest");
mtCommand.push_back(this->LinkerManifestFile);
}
cm::append(mtCommand, this->UserManifests);
for (auto const& m : this->UserManifests) {
mtCommand.emplace_back("/manifest");
mtCommand.push_back(m);
}
mtCommand.push_back(out);
if (notify) {
// Add an undocumented option that enables a special return