浏览代码

fileapi: Fix codemodel-v2 link command fragment relative paths

Use the same `cmLinkLineComputer` subclass as the generator does.  This
affects the base directory from which relative paths are computed.

Fixes: #22301
Brad King 4 年之前
父节点
当前提交
68bbec66e0
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      Source/cmFileAPICodemodel.cxx

+ 5 - 4
Source/cmFileAPICodemodel.cxx

@@ -27,7 +27,7 @@
 #include "cmInstallGenerator.h"
 #include "cmInstallSubdirectoryGenerator.h"
 #include "cmInstallTargetGenerator.h"
-#include "cmLinkLineComputer.h"
+#include "cmLinkLineComputer.h" // IWYU pragma: keep
 #include "cmListFileCache.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
@@ -1444,9 +1444,10 @@ Json::Value Target::DumpLinkCommandFragments()
   std::vector<BT<std::string>> linkPath;
   std::vector<BT<std::string>> linkLibs;
   cmLocalGenerator* lg = this->GT->GetLocalGenerator();
-  cmLinkLineComputer linkLineComputer(lg,
-                                      lg->GetStateSnapshot().GetDirectory());
-  lg->GetTargetFlags(&linkLineComputer, this->Config, linkLibs,
+  cmGlobalGenerator* gg = this->GT->GetGlobalGenerator();
+  std::unique_ptr<cmLinkLineComputer> linkLineComputer =
+    gg->CreateLinkLineComputer(lg, lg->GetStateSnapshot().GetDirectory());
+  lg->GetTargetFlags(linkLineComputer.get(), this->Config, linkLibs,
                      linkLanguageFlags, linkFlags, frameworkPath, linkPath,
                      this->GT);
   linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags);