فهرست منبع

cmLocalGenerator: move the `CMakeFiles` subdir from the target to output root

When target directories are shortened, the `CMakeFiles` path component
will be part of the root, not the target directory. Since other files
end up constructing paths manually, move the differing component into
the correct logical path construction part.
Ben Boeckel 6 ماه پیش
والد
کامیت
35d32b8741

+ 1 - 1
Source/cmLocalCommonGenerator.cxx

@@ -92,7 +92,7 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
 std::string cmLocalCommonGenerator::GetTargetDirectory(
   cmGeneratorTarget const* target) const
 {
-  std::string dir = cmStrCat("CMakeFiles/", target->GetName());
+  std::string dir = target->GetName();
 #if defined(__VMS)
   dir += "_dir";
 #else

+ 1 - 1
Source/cmLocalGenerator.cxx

@@ -4288,7 +4288,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
 
 std::string cmLocalGenerator::GetObjectOutputRoot() const
 {
-  return this->GetCurrentBinaryDirectory();
+  return cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
 }
 
 std::string cmLocalGenerator::GetSourceFileLanguage(cmSourceFile const& source)

+ 3 - 1
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1150,11 +1150,13 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
     std::set<std::string> languages;
     target->GetLanguages(
       languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    auto langFileDir = cmSystemTools::GetFilenamePath(
+      this->MaybeRelativeToCurBinDir(cleanfile));
     /* clang-format off */
     fout << "\n"
             "# Per-language clean rules from dependency scanning.\n"
             "foreach(lang " << cmJoin(languages, " ") << ")\n"
-            "  include(" << this->GetTargetDirectory(target)
+            "  include(" << langFileDir
          << "/cmake_clean_${lang}.cmake OPTIONAL)\n"
             "endforeach()\n";
     /* clang-format on */

+ 5 - 0
Source/cmLocalVisualStudioGenerator.cxx

@@ -84,6 +84,11 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
   }
 }
 
+std::string cmLocalVisualStudioGenerator::GetObjectOutputRoot() const
+{
+  return this->GetCurrentBinaryDirectory();
+}
+
 std::unique_ptr<cmCustomCommand>
 cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
                                                    std::string const& config,

+ 2 - 0
Source/cmLocalVisualStudioGenerator.h

@@ -51,6 +51,8 @@ public:
     std::map<cmSourceFile const*, std::string>& mapping,
     cmGeneratorTarget const* = nullptr) override;
 
+  std::string GetObjectOutputRoot() const override;
+
 protected:
   virtual char const* ReportErrorLabel() const;
   virtual bool CustomCommandUseLocal() const { return false; }

+ 3 - 0
Source/cmQtAutoGenInitializer.cxx

@@ -462,6 +462,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
       std::string(), this->Makefile->GetCurrentBinaryDirectory());
 
     // Info directory
+    // TODO: Split this? `AutogenInfo.json` is expected to always be under the
+    // `CMakeFiles` directory, but not all generators places its `<tgt>.dir`
+    // directories there.
     this->Dir.Info = cmStrCat(cbd, "/CMakeFiles/", this->GenTarget->GetName(),
                               "_autogen.dir");
     cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);