Explorar o código

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 hai 6 meses
pai
achega
35d32b8741

+ 1 - 1
Source/cmLocalCommonGenerator.cxx

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

+ 1 - 1
Source/cmLocalGenerator.cxx

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

+ 3 - 1
Source/cmLocalUnixMakefileGenerator3.cxx

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

+ 2 - 0
Source/cmLocalVisualStudioGenerator.h

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

+ 3 - 0
Source/cmQtAutoGenInitializer.cxx

@@ -462,6 +462,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
       std::string(), this->Makefile->GetCurrentBinaryDirectory());
       std::string(), this->Makefile->GetCurrentBinaryDirectory());
 
 
     // Info directory
     // 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(),
     this->Dir.Info = cmStrCat(cbd, "/CMakeFiles/", this->GenTarget->GetName(),
                               "_autogen.dir");
                               "_autogen.dir");
     cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);
     cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);