Merge topic 'msvc-llvm-mt'

3c0f701990 MSVC: Run manifest tool with llvm-mt compatible arguments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8706
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index f778891..431d00b 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -82,7 +82,7 @@
   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)
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index b18f5cf..2ac9d8e 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -2539,14 +2539,17 @@
   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