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.
This commit is contained in:
Ben Boeckel
2025-05-21 21:09:08 +02:00
parent bc19e42461
commit 35d32b8741
6 changed files with 15 additions and 3 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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,

View File

@@ -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; }

View File

@@ -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);