generators: use GetSupportDirectory() in more places

This commit is contained in:
Ben Boeckel
2025-05-23 11:39:53 +02:00
parent 36f85ee0cc
commit b82a74d918
19 changed files with 69 additions and 98 deletions
+1 -2
View File
@@ -196,8 +196,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories(
((lang == "CXX"_s && linkee->HaveCxx20ModuleSources()) ||
(lang == "Fortran"_s && linkee->HaveFortranSources(config)))) {
cmLocalGenerator* lg = linkee->GetLocalGenerator();
std::string di = cmStrCat(lg->GetCurrentBinaryDirectory(), '/',
lg->GetTargetDirectory(linkee));
std::string di = linkee->GetSupportDirectory();
if (lg->GetGlobalGenerator()->IsMultiConfig()) {
di = cmStrCat(di, '/', config);
}
+4 -6
View File
@@ -461,14 +461,13 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// Write a dummy file for OBJECT libraries, so C::B can reference some file
std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
cmLocalGenerator* lg, cmGeneratorTarget* target) const
cmGeneratorTarget* target) const
{
// this file doesn't seem to be used by C::B in custom makefile mode,
// but we generate a unique file for each OBJECT library so in case
// C::B uses it in some way, the targets don't interfere with each other.
std::string filename = cmStrCat(lg->GetCurrentBinaryDirectory(), '/',
lg->GetTargetDirectory(target), '/',
target->GetName(), ".objlib");
std::string filename =
cmStrCat(target->GetSupportDirectory(), '/', target->GetName(), ".objlib");
cmGeneratedFileStream fout(filename);
if (fout) {
/* clang-format off */
@@ -516,8 +515,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
std::string buildType = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
std::string location;
if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
location =
this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg), target);
location = this->CreateDummyTargetFile(target);
} else {
location = target->GetLocation(buildType);
}
+1 -2
View File
@@ -36,8 +36,7 @@ private:
void CreateNewProjectFile(std::vector<cmLocalGenerator*> const& lgs,
std::string const& filename);
std::string CreateDummyTargetFile(cmLocalGenerator* lg,
cmGeneratorTarget* target) const;
std::string CreateDummyTargetFile(cmGeneratorTarget* target) const;
std::string GetCBCompilerId(cmMakefile const* mf);
int GetCBTargetType(cmGeneratorTarget* target);
@@ -81,8 +81,7 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
if (mode == IncludeDirectoryFallBack::BINARY) {
value = lg->GetCurrentBinaryDirectory();
} else if (mode == IncludeDirectoryFallBack::OBJECT) {
value = cmStrCat(lg->GetCurrentBinaryDirectory(), '/',
lg->GetTargetDirectory(dependency));
value = dependency->GetSupportDirectory();
}
}
+9 -18
View File
@@ -132,9 +132,8 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
// Open the target file in copy-if-different mode.
std::string fproj =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
'/', this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
cmStrCat(this->GeneratorTarget->GetSupportDirectory(), '/', this->Name,
cmGlobalGhsMultiGenerator::FILE_EXTENSION);
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME", fproj);
@@ -179,9 +178,7 @@ void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
*/
if (this->TagType != GhsMultiGpj::SUBPROJECT) {
// set target binary file destination
std::string binpath = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
std::string binpath = this->GeneratorTarget->GetSupportDirectory();
outpath = cmSystemTools::RelativePath(
binpath, this->GeneratorTarget->GetDirectory(config));
/* clang-format off */
@@ -386,10 +383,8 @@ void cmGhsMultiTargetGenerator::WriteBuildEventsHelper(
for (cmCustomCommand const& cc : ccv) {
cmCustomCommandGenerator ccg(cc, this->ConfigName, this->LocalGenerator);
// Open the filestream for this custom command
std::string fname =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
'/', this->Name, '_', name, cmdcount++, fext);
std::string fname = cmStrCat(this->GeneratorTarget->GetSupportDirectory(),
'/', this->Name, '_', name, cmdcount++, fext);
cmGeneratedFileStream f(fname);
f.SetCopyIfDifferent(true);
@@ -604,10 +599,8 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
cmsys::SystemTools::ReplaceString(gname, "\\", "_");
std::string lpath =
cmStrCat(gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
std::string fpath = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
lpath);
std::string fpath =
cmStrCat(this->GeneratorTarget->GetSupportDirectory(), '/', lpath);
cmGeneratedFileStream* f = new cmGeneratedFileStream(fpath);
f->SetCopyIfDifferent(true);
gfiles.push_back(f);
@@ -700,10 +693,8 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
// Open the filestream for this custom command
std::string fname = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
'/', this->Name, "_cc", cmdcount++, '_',
(sf->GetLocation()).GetName(), fext);
this->GeneratorTarget->GetSupportDirectory(), '/', this->Name,
"_cc", cmdcount++, '_', (sf->GetLocation()).GetName(), fext);
cmGeneratedFileStream f(fname);
f.SetCopyIfDifferent(true);
+1 -3
View File
@@ -69,9 +69,7 @@ void cmGlobalGhsMultiGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
// Compute full path to object file directory for this target.
std::string dir =
cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/',
gt->LocalGenerator->GetTargetDirectory(gt), '/');
std::string dir = cmStrCat(gt->GetSupportDirectory(), '/');
gt->ObjectDirectory = dir;
}
+2 -3
View File
@@ -1052,9 +1052,8 @@ void cmGlobalNinjaGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
// Compute full path to object file directory for this target.
std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', gt->LocalGenerator->GetTargetDirectory(gt),
'/', this->GetCMakeCFGIntDir(), '/');
std::string dir =
cmStrCat(gt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir(), '/');
gt->ObjectDirectory = dir;
}
+1 -3
View File
@@ -81,9 +81,7 @@ void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
// Compute full path to object file directory for this target.
std::string dir =
cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/',
gt->LocalGenerator->GetTargetDirectory(gt), '/');
std::string dir = cmStrCat(gt->GetSupportDirectory(), '/');
gt->ObjectDirectory = dir;
}
+6 -1
View File
@@ -619,13 +619,18 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
"\t<Configurations>\n"
;
/* clang-format on */
std::string intDirPrefix =
target->GetLocalGenerator()->MaybeRelativeToCurBinDir(
cmStrCat(target->GetSupportDirectory(), '\\'));
for (std::string const& i : configs) {
std::string intDir = cmStrCat(intDir, i);
/* clang-format off */
fout <<
"\t\t<Configuration\n"
"\t\t\tName=\"" << i << "|Win32\"\n"
"\t\t\tOutputDirectory=\"" << i << "\"\n"
"\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << i << "\"\n"
"\t\t\tIntermediateDirectory=\"" << intDir << "\"\n"
"\t\t\tConfigurationType=\"10\"\n"
"\t\t\tUseOfMFC=\"0\"\n"
"\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
+2 -3
View File
@@ -225,9 +225,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
void cmGlobalVisualStudioGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', gt->LocalGenerator->GetTargetDirectory(gt),
'/', this->GetCMakeCFGIntDir(), '/');
std::string dir =
cmStrCat(gt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir(), '/');
gt->ObjectDirectory = dir;
}
+1 -3
View File
@@ -5344,9 +5344,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
cmGeneratorTarget* target)
{
std::string plist =
cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
"/CMakeFiles/", target->GetName(), ".dir/Info.plist");
std::string plist = cmStrCat(target->GetSupportDirectory(), "/Info.plist");
return plist;
}
+1 -2
View File
@@ -3323,8 +3323,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
}
std::string filename_base =
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/",
target->GetName(), ".dir/Unity/");
cmStrCat(target->GetSupportDirectory(), "/Unity/");
cmValue batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE");
size_t const unityBatchSize = batchSizeString
+1 -2
View File
@@ -44,8 +44,7 @@ void cmLocalGhsMultiGenerator::ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
cmGeneratorTarget const* gt)
{
std::string dir_max = cmStrCat(this->GetCurrentBinaryDirectory(), '/',
this->GetTargetDirectory(gt), '/');
std::string dir_max = cmStrCat(gt->GetSupportDirectory(), '/');
// Count the number of object files with each name. Note that
// filesystem may not be case sensitive.
+4 -8
View File
@@ -224,8 +224,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources, this->GetConfigName());
// Compute full path to object file directory for this target.
std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', this->GetTargetDirectory(gt.get()), '/');
std::string dir = cmStrCat(gt->GetSupportDirectory(), '/');
// Compute the name of each object file.
for (cmSourceFile const* sf : objectSources) {
bool hasSourceExtension = true;
@@ -891,9 +890,7 @@ void cmLocalUnixMakefileGenerator3::WriteConvenienceRule(
std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(
cmGeneratorTarget const* target) const
{
std::string dir =
cmStrCat(this->HomeRelativeOutputPath, this->GetTargetDirectory(target));
return dir;
return this->MaybeRelativeToTopBinDir(target->GetSupportDirectory());
}
void cmLocalUnixMakefileGenerator3::AppendFlags(
@@ -1120,9 +1117,8 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
std::vector<std::string>& commands, std::set<std::string> const& files,
cmGeneratorTarget* target, char const* filename)
{
std::string currentBinDir = this->GetCurrentBinaryDirectory();
std::string cleanfile = cmStrCat(
currentBinDir, '/', this->GetTargetDirectory(target), "/cmake_clean");
std::string cleanfile =
cmStrCat(target->GetSupportDirectory(), "/cmake_clean");
if (filename) {
cleanfile += "_";
cleanfile += filename;
+6 -7
View File
@@ -771,8 +771,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
// The intermediate directory name consists of a directory for the
// target and a subdirectory for the configuration name.
std::string intermediateDir =
cmStrCat(this->GetTargetDirectory(target), '/', configName);
std::string intermediateDir = this->MaybeRelativeToCurBinDir(
cmStrCat(target->GetSupportDirectory(), '/', configName));
if (target->GetType() < cmStateEnums::UTILITY) {
std::string const& outDir =
@@ -1019,9 +1019,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
case cmStateEnums::UNKNOWN_LIBRARY:
break;
case cmStateEnums::OBJECT_LIBRARY: {
std::string libpath =
cmStrCat(this->GetTargetDirectory(target), '/', configName, '/',
target->GetName(), ".lib");
std::string libpath = this->MaybeRelativeToCurBinDir(
cmStrCat(target->GetSupportDirectory(), '/', configName, '/',
target->GetName(), ".lib"));
char const* tool =
this->FortranProject ? "VFLibrarianTool" : "VCLibrarianTool";
fout << "\t\t\t<Tool\n"
@@ -1661,8 +1661,7 @@ std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory(
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
std::string dir_max =
cmStrCat(this->GetCurrentBinaryDirectory(), '/',
this->GetTargetDirectory(target), '/', config_max, '/');
cmStrCat(target->GetSupportDirectory(), '/', config_max, '/');
return dir_max;
}
+3 -3
View File
@@ -165,10 +165,10 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags(
void cmMakefileTargetGenerator::CreateRuleFile()
{
// Create a directory for this target.
this->TargetBuildDirectory =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->TargetBuildDirectoryFull =
this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory);
this->GeneratorTarget->GetSupportDirectory();
this->TargetBuildDirectory = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->TargetBuildDirectoryFull);
cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull);
// Construct the rule file name.
+6 -4
View File
@@ -844,8 +844,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement(
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
std::string targetOutputDir =
cmStrCat(this->GetLocalGenerator()->GetTargetDirectory(genTarget),
globalGen->ConfigDirectory(config), '/');
this->GetLocalGenerator()->MaybeRelativeToTopBinDir(
cmStrCat(genTarget->GetSupportDirectory(),
globalGen->ConfigDirectory(config), '/'));
targetOutputDir = globalGen->ExpandCFGIntDir(targetOutputDir, config);
std::string targetOutputReal =
@@ -980,8 +981,9 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkStatement(
if (config != fileConfig) {
std::string targetOutputFileConfigDir =
cmStrCat(this->GetLocalGenerator()->GetTargetDirectory(genTarget),
globalGen->ConfigDirectory(fileConfig), '/');
this->GetLocalGenerator()->MaybeRelativeToTopBinDir(
cmStrCat(genTarget->GetSupportDirectory(),
globalGen->ConfigDirectory(config), '/'));
targetOutputFileConfigDir =
globalGen->ExpandCFGIntDir(outputDir, fileConfig);
if (outputDir == targetOutputFileConfigDir) {
+3 -8
View File
@@ -412,14 +412,9 @@ std::string cmNinjaTargetGenerator::GetCompiledSourceNinjaPath(
std::string cmNinjaTargetGenerator::GetObjectFileDir(
std::string const& config) const
{
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) {
path += '/';
}
path +=
cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
this->GetGlobalGenerator()->ConfigDirectory(config));
return path;
return this->LocalGenerator->MaybeRelativeToTopBinDir(
cmStrCat(this->GeneratorTarget->GetSupportDirectory(),
this->GetGlobalGenerator()->GetConfigDirectory(config)));
}
std::string cmNinjaTargetGenerator::GetObjectFilePath(
+16 -18
View File
@@ -300,9 +300,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
&this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
&this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
this->MSTools = !this->NsightTegra && !this->Android;
this->DefaultArtifactDir =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
this->DefaultArtifactDir = this->GeneratorTarget->GetSupportDirectory();
this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
this->Makefile->GetCurrentBinaryDirectory());
this->ClassifyAllConfigSources();
@@ -3094,9 +3092,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
}
}
std::string intermediateDir = cmStrCat(
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
config, '/');
std::string intermediateDir =
this->LocalGenerator->MaybeRelativeToCurBinDir(cmStrCat(
this->GeneratorTarget->GetSupportDirectory(), '/', config, '/'));
std::string outDir;
std::string targetNameFull;
if (ttype == cmStateEnums::OBJECT_LIBRARY) {
@@ -5255,8 +5253,8 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
!(this->GlobalGenerator->TargetsWindowsPhone() &&
this->GlobalGenerator->GetSystemVersion() == "8.0"_s)) {
// Move the manifest to a project directory to avoid clashes
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
Elem e1(e0, "PropertyGroup");
e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, '\\'));
@@ -5507,8 +5505,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
// folders
std::string manifestFile = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), "/WMAppManifest.xml");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string const& targetNameXML = cmVS10EscapeXML(GetTargetOutputName());
@@ -5589,8 +5587,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1)
{
std::string manifestFile =
cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string const& targetNameXML = cmVS10EscapeXML(GetTargetOutputName());
@@ -5651,8 +5649,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1)
{
std::string manifestFile =
cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string const& targetNameXML = cmVS10EscapeXML(GetTargetOutputName());
@@ -5705,8 +5703,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1)
{
std::string manifestFile =
cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string const& targetNameXML = cmVS10EscapeXML(GetTargetOutputName());
@@ -5764,8 +5762,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1)
{
std::string manifestFile =
cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
std::string artifactDir = this->LocalGenerator->MaybeRelativeToCurBinDir(
this->GeneratorTarget->GetSupportDirectory());
ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string const& targetNameXML = cmVS10EscapeXML(GetTargetOutputName());