浏览代码

cmFileCommand: improve error message

Print full list of unresolved dependencies and a phrase that indicates
what about the file is unresolved.
Seth R Johnson 4 年之前
父节点
当前提交
fc92d6640b

+ 6 - 3
Source/cmFileCommand.cxx

@@ -3170,9 +3170,12 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
                             archive.GetUnresolvedPaths().begin(),
                             archive.GetUnresolvedPaths().end());
     } else {
-      auto it = archive.GetUnresolvedPaths().begin();
-      assert(it != archive.GetUnresolvedPaths().end());
-      status.SetError(cmStrCat("Could not resolve file ", *it));
+      std::ostringstream e;
+      e << "Could not resolve runtime dependencies:";
+      for (auto const& path : archive.GetUnresolvedPaths()) {
+        e << "\n  " << path;
+      }
+      status.SetError(e.str());
       cmSystemTools::SetFatalErrorOccured();
       return false;
     }

+ 3 - 1
Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/linux-notfile-all-stderr.txt

@@ -1,2 +1,4 @@
 ^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
-  file Could not resolve file libtest\.so$
+  file Could not resolve runtime dependencies:
+
+    libtest\.so$

+ 3 - 1
Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/linux-unresolved-all-stderr.txt

@@ -1,2 +1,4 @@
 ^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
-  file Could not resolve file libunresolved\.so$
+  file Could not resolve runtime dependencies:
+
+    libunresolved\.so$

+ 3 - 1
Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-unresolved-all-stderr.txt

@@ -1,2 +1,4 @@
 ^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
-  file Could not resolve file @rpath/libunresolved\.dylib$
+  file Could not resolve runtime dependencies:
+
+    @rpath/libunresolved\.dylib$

+ 3 - 1
Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr.txt

@@ -1,2 +1,4 @@
 ^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
-  file Could not resolve file (lib)?unresolved\.dll$
+  file Could not resolve runtime dependencies:
+
+    (lib)?unresolved\.dll$