mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
cmGeneratorTarget: Replace GetFullPath realname parameter with an enum
This makes call sites more readable.
This commit is contained in:
1 parent
84a54323d3
commit
edd2712a34
12 files changed
+55
-34
No files matched your search
@@ -1151,7 +1151,8 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
||||
cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config)
|
||||
? cmStateEnums::ImportLibraryArtifact
|
||||
: cmStateEnums::RuntimeBinaryArtifact;
|
||||
std::string exe = tgt->GetFullPath(config, artifact, true);
|
||||
std::string exe =
|
||||
tgt->GetFullPath(config, artifact, cmGeneratorTarget::NameType::Real);
|
||||
this->Items.emplace_back(
|
||||
BT<std::string>(exe, item.Backtrace), ItemIsPath::Yes, tgt, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
@@ -1186,7 +1187,8 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
||||
|
||||
// Pass the full path to the target file.
|
||||
BT<std::string> lib = BT<std::string>(
|
||||
tgt->GetFullPath(config, artifact, true), item.Backtrace);
|
||||
tgt->GetFullPath(config, artifact, cmGeneratorTarget::NameType::Real),
|
||||
item.Backtrace);
|
||||
if (tgt->IsAIX() && cmHasLiteralSuffix(lib.Value, "-NOTFOUND") &&
|
||||
artifact == cmStateEnums::ImportLibraryArtifact) {
|
||||
// This is an imported executable on AIX that has ENABLE_EXPORTS
|
||||
@@ -1207,7 +1209,8 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
||||
if (tgt->IsApple() && tgt->HasImportLibrary(config)) {
|
||||
// Use the library rather than the tbd file for runpath computation
|
||||
this->AddLibraryRuntimeInfo(
|
||||
tgt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact, true),
|
||||
tgt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Real),
|
||||
tgt);
|
||||
} else {
|
||||
this->AddLibraryRuntimeInfo(lib.Value, tgt);
|
||||
@@ -1336,7 +1339,7 @@ void cmComputeLinkInformation::AddSharedDepItem(LinkEntry const& entry)
|
||||
// Use the library rather than the tbd file for runpath computation
|
||||
this->AddLibraryRuntimeInfo(
|
||||
tgt->GetFullPath(this->Config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
true),
|
||||
cmGeneratorTarget::NameType::Real),
|
||||
tgt);
|
||||
} else {
|
||||
this->AddLibraryRuntimeInfo(lib, tgt);
|
||||
|
||||
@@ -101,8 +101,9 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
|
||||
value =
|
||||
target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
|
||||
} else {
|
||||
value = target->GetFullPath(config,
|
||||
cmStateEnums::RuntimeBinaryArtifact, true);
|
||||
value =
|
||||
target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
}
|
||||
properties[prop] = value;
|
||||
}
|
||||
@@ -111,7 +112,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
|
||||
if (target->HasImportLibrary(config)) {
|
||||
std::string prop = cmStrCat("IMPORTED_IMPLIB", suffix);
|
||||
std::string value =
|
||||
target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact, true);
|
||||
target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact,
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
if (mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
|
||||
target->GetImplibGNUtoMS(config, value, value,
|
||||
"${CMAKE_IMPORT_LIBRARY_SUFFIX}");
|
||||
|
||||
@@ -443,7 +443,7 @@ void cmFastbuildNormalTargetGenerator::ApplyLWYUToLinkerCommand(
|
||||
std::move(args), " --source=",
|
||||
this->ConvertToFastbuildPath(this->GetGeneratorTarget()->GetFullPath(
|
||||
Config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true)));
|
||||
cmGeneratorTarget::NameType::Real)));
|
||||
|
||||
LogMessage("LWUY args: " + args);
|
||||
linkerNode.LinkerStampExe = cmSystemTools::GetCMakeCommand();
|
||||
@@ -1880,8 +1880,9 @@ std::string cmFastbuildNormalTargetGenerator::GetImportedLoc(
|
||||
? cmStateEnums::ImportLibraryArtifact
|
||||
: cmStateEnums::RuntimeBinaryArtifact;
|
||||
|
||||
std::string importedLoc = this->ConvertToFastbuildPath(
|
||||
item.Target->GetFullPath(Config, artifact, true));
|
||||
std::string importedLoc =
|
||||
this->ConvertToFastbuildPath(item.Target->GetFullPath(
|
||||
Config, artifact, cmGeneratorTarget::NameType::Real));
|
||||
LogMessage("ImportedGetLocation: " + importedLoc);
|
||||
return importedLoc;
|
||||
}
|
||||
@@ -2359,7 +2360,7 @@ void cmFastbuildNormalTargetGenerator::GenerateLink(
|
||||
ConvertToFastbuildPath(GeneratorTarget->GetFullPath(Config));
|
||||
std::string targetOutputReal = ConvertToFastbuildPath(
|
||||
GeneratorTarget->GetFullPath(Config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true));
|
||||
cmGeneratorTarget::NameType::Real));
|
||||
LogMessage("targetOutput: " + targetOutput);
|
||||
LogMessage("targetOutputReal: " + targetOutputReal);
|
||||
|
||||
@@ -2464,7 +2465,7 @@ cmFastbuildNormalTargetGenerator::GetSymlinkExecs() const
|
||||
ConvertToFastbuildPath(GeneratorTarget->GetFullPath(Config));
|
||||
std::string const targetOutputReal = ConvertToFastbuildPath(
|
||||
GeneratorTarget->GetFullPath(Config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true));
|
||||
cmGeneratorTarget::NameType::Real));
|
||||
LogMessage("targetOutput: " + targetOutput);
|
||||
|
||||
LogMessage("targetOutputReal: " + targetOutputReal);
|
||||
|
||||
@@ -2362,7 +2362,8 @@ Json::Value Target::DumpArtifacts()
|
||||
}
|
||||
} else {
|
||||
fullPath = this->GT->NormalGetFullPath(
|
||||
this->Config, cmStateEnums::ImportLibraryArtifact, false);
|
||||
this->Config, cmStateEnums::ImportLibraryArtifact,
|
||||
cmGeneratorTarget::NameType::Output);
|
||||
}
|
||||
if (!fullPath.empty()) {
|
||||
Json::Value artifact = Json::objectValue;
|
||||
|
||||
@@ -5827,7 +5827,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag>
|
||||
GeneratorExpressionContent const* /*unused*/)
|
||||
{
|
||||
return target->GetFullPath(eval->Context.Config,
|
||||
cmStateEnums::RuntimeBinaryArtifact, true);
|
||||
cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5840,7 +5841,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactImportTag>
|
||||
{
|
||||
if (target->HasImportLibrary(eval->Context.Config)) {
|
||||
return target->GetFullPath(eval->Context.Config,
|
||||
cmStateEnums::ImportLibraryArtifact, true);
|
||||
cmStateEnums::ImportLibraryArtifact,
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
}
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
@@ -3915,17 +3915,17 @@ std::string cmGeneratorTarget::GetImportedLibName(
|
||||
|
||||
std::string cmGeneratorTarget::GetFullPath(std::string const& config,
|
||||
cmStateEnums::ArtifactType artifact,
|
||||
bool realname) const
|
||||
NameType nameType) const
|
||||
{
|
||||
if (this->IsImported()) {
|
||||
return this->Target->ImportedGetFullPath(config, artifact);
|
||||
}
|
||||
return this->NormalGetFullPath(config, artifact, realname);
|
||||
return this->NormalGetFullPath(config, artifact, nameType);
|
||||
}
|
||||
|
||||
std::string cmGeneratorTarget::NormalGetFullPath(
|
||||
std::string const& config, cmStateEnums::ArtifactType artifact,
|
||||
bool realname) const
|
||||
NameType nameType) const
|
||||
{
|
||||
std::string fpath = cmStrCat(this->GetDirectory(config, artifact), '/');
|
||||
if (this->IsAppBundleOnApple()) {
|
||||
@@ -3936,7 +3936,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(
|
||||
// Add the full name of the target.
|
||||
switch (artifact) {
|
||||
case cmStateEnums::RuntimeBinaryArtifact:
|
||||
if (realname) {
|
||||
if (nameType == NameType::Real) {
|
||||
fpath += this->NormalGetRealName(config);
|
||||
} else {
|
||||
fpath +=
|
||||
@@ -3944,7 +3944,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(
|
||||
}
|
||||
break;
|
||||
case cmStateEnums::ImportLibraryArtifact:
|
||||
if (realname) {
|
||||
if (nameType == NameType::Real) {
|
||||
fpath +=
|
||||
this->NormalGetRealName(config, cmStateEnums::ImportLibraryArtifact);
|
||||
} else {
|
||||
|
||||
@@ -313,15 +313,22 @@ public:
|
||||
/** Get the library name for an imported interface library. */
|
||||
std::string GetImportedLibName(std::string const& config) const;
|
||||
|
||||
/** Which file name to use for the last component of a target's path. */
|
||||
enum class NameType
|
||||
{
|
||||
Output, // The name that other build rules refer to, e.g. libfoo.so.
|
||||
Real, // The name of the real file, e.g. libfoo.so.1.2.3.
|
||||
};
|
||||
|
||||
/** Get the full path to the target according to the settings in its
|
||||
makefile and the configuration type. */
|
||||
std::string GetFullPath(
|
||||
std::string const& config,
|
||||
cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact,
|
||||
bool realname = false) const;
|
||||
NameType nameType = NameType::Output) const;
|
||||
std::string NormalGetFullPath(std::string const& config,
|
||||
cmStateEnums::ArtifactType artifact,
|
||||
bool realname) const;
|
||||
NameType nameType) const;
|
||||
std::string NormalGetRealName(std::string const& config,
|
||||
cmStateEnums::ArtifactType artifact =
|
||||
cmStateEnums::RuntimeBinaryArtifact) const;
|
||||
|
||||
@@ -2498,10 +2498,12 @@ cmGeneratorTarget* cmGlobalGenerator::FindArtifactOwningTarget(
|
||||
continue;
|
||||
}
|
||||
std::set<std::string> artifacts;
|
||||
artifacts.insert(cmSystemTools::CollapseFullPath(gt->GetFullPath(
|
||||
config, cmStateEnums::RuntimeBinaryArtifact, /*realname=*/false)));
|
||||
artifacts.insert(cmSystemTools::CollapseFullPath(gt->GetFullPath(
|
||||
config, cmStateEnums::RuntimeBinaryArtifact, /*realname=*/true)));
|
||||
artifacts.insert(cmSystemTools::CollapseFullPath(
|
||||
gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Output)));
|
||||
artifacts.insert(cmSystemTools::CollapseFullPath(
|
||||
gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Real)));
|
||||
if (gt->HasImportLibrary(config)) {
|
||||
artifacts.insert(cmSystemTools::CollapseFullPath(
|
||||
gt->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)));
|
||||
|
||||
@@ -1542,7 +1542,9 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
|
||||
// frameworks always appear versioned, and the build.ninja
|
||||
// will always attempt to manage symbolic links instead
|
||||
// of letting cmOSXBundleGenerator do it.
|
||||
bool realname = target->IsFrameworkOnApple();
|
||||
cmGeneratorTarget::NameType nameType = target->IsFrameworkOnApple()
|
||||
? cmGeneratorTarget::NameType::Real
|
||||
: cmGeneratorTarget::NameType::Output;
|
||||
|
||||
switch (target->GetType()) {
|
||||
case cm::TargetType::SHARED_LIBRARY:
|
||||
@@ -1557,10 +1559,10 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
|
||||
case cm::TargetType::EXECUTABLE: {
|
||||
if (target->IsApple() && target->HasImportLibrary(config)) {
|
||||
outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath(
|
||||
config, cmStateEnums::ImportLibraryArtifact, realname)));
|
||||
config, cmStateEnums::ImportLibraryArtifact, nameType)));
|
||||
}
|
||||
outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath(
|
||||
config, cmStateEnums::RuntimeBinaryArtifact, realname)));
|
||||
config, cmStateEnums::RuntimeBinaryArtifact, nameType)));
|
||||
break;
|
||||
}
|
||||
case cm::TargetType::OBJECT_LIBRARY: {
|
||||
|
||||
@@ -2589,7 +2589,7 @@ bool cmLocalGenerator::GetRealDependency(std::string const& inName,
|
||||
case cm::TargetType::MODULE_LIBRARY:
|
||||
case cm::TargetType::UNKNOWN_LIBRARY:
|
||||
dep = target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true);
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
return true;
|
||||
case cm::TargetType::OBJECT_LIBRARY:
|
||||
// An object library has no single file on which to depend.
|
||||
|
||||
@@ -923,7 +923,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
|
||||
this->GeneratorTarget->GetType() == cm::TargetType::SHARED_LIBRARY ||
|
||||
this->GeneratorTarget->GetType() == cm::TargetType::MODULE_LIBRARY) {
|
||||
targetFullPathReal = this->GeneratorTarget->GetFullPath(
|
||||
this->GetConfigName(), cmStateEnums::RuntimeBinaryArtifact, true);
|
||||
this->GetConfigName(), cmStateEnums::RuntimeBinaryArtifact,
|
||||
cmGeneratorTarget::NameType::Real);
|
||||
targetFullPathPDB = cmStrCat(
|
||||
this->GeneratorTarget->GetPDBDirectory(this->GetConfigName()), '/',
|
||||
this->GeneratorTarget->GetPDBName(this->GetConfigName()));
|
||||
|
||||
@@ -781,7 +781,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd(
|
||||
std::string targetOutputReal =
|
||||
this->ConvertToNinjaPath(this->GetGeneratorTarget()->GetFullPath(
|
||||
config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true));
|
||||
cmGeneratorTarget::NameType::Real));
|
||||
cmakeCommand =
|
||||
cmStrCat(std::move(cmakeCommand), " --source=", targetOutputReal);
|
||||
linkCmds.push_back(std::move(cmakeCommand));
|
||||
@@ -1173,7 +1173,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
std::string targetOutput = this->ConvertToNinjaPath(gt->GetFullPath(config));
|
||||
std::string targetOutputReal = this->ConvertToNinjaPath(
|
||||
gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true));
|
||||
cmGeneratorTarget::NameType::Real));
|
||||
std::string targetOutputImplib = this->ConvertToNinjaPath(
|
||||
gt->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
|
||||
|
||||
@@ -1185,7 +1185,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
if (targetOutputReal ==
|
||||
this->ConvertToNinjaPath(
|
||||
gt->GetFullPath(fileConfig, cmStateEnums::RuntimeBinaryArtifact,
|
||||
/*realname=*/true))) {
|
||||
cmGeneratorTarget::NameType::Real))) {
|
||||
return;
|
||||
}
|
||||
if (!gt->GetFullName(config, cmStateEnums::ImportLibraryArtifact)
|
||||
|
||||
Reference in new issue
Block a user