cmTarget: Add HasKnownObjectFileLocation()
shorthand
Allow `cmGlobalGenerator`s to decide `HasKnownObjectFileLocation()` per given `cmTarget` - `cmGlobalGenerator::HasKnownObjectFileLocation()` now takes an optional `cmGeneratorTarget` - `cmTarget::HasKnownObjectFileLocation()` added as a shorthand
This commit is contained in:
parent
7fc248bde3
commit
41ba35a42b
@ -195,7 +195,7 @@ cmStateEnums::TargetType cmExportBuildFileGenerator::GetExportTargetType(
|
||||
// to support transitive usage requirements on other targets that
|
||||
// use the object library.
|
||||
if (targetType == cmStateEnums::OBJECT_LIBRARY &&
|
||||
!this->LG->GetGlobalGenerator()->HasKnownObjectFileLocation(nullptr)) {
|
||||
!target->Target->HasKnownObjectFileLocation(nullptr)) {
|
||||
targetType = cmStateEnums::INTERFACE_LIBRARY;
|
||||
}
|
||||
return targetType;
|
||||
|
@ -1728,7 +1728,7 @@ Json::Value Target::DumpArtifacts()
|
||||
|
||||
// Object libraries have only object files as artifacts.
|
||||
if (this->GT->GetType() == cmStateEnums::OBJECT_LIBRARY) {
|
||||
if (!this->GT->GetGlobalGenerator()->HasKnownObjectFileLocation(nullptr)) {
|
||||
if (!this->GT->Target->HasKnownObjectFileLocation(nullptr)) {
|
||||
return artifacts;
|
||||
}
|
||||
std::vector<cmSourceFile const*> objectSources;
|
||||
|
@ -1785,7 +1785,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
std::string reason;
|
||||
if (!context->EvaluateForBuildsystem &&
|
||||
!gg->HasKnownObjectFileLocation(&reason)) {
|
||||
!gt->Target->HasKnownObjectFileLocation(&reason)) {
|
||||
std::ostringstream e;
|
||||
e << "The evaluation of the TARGET_OBJECTS generator expression "
|
||||
"is only suitable for consumption by CMake (limited"
|
||||
|
@ -459,10 +459,13 @@ public:
|
||||
|
||||
virtual bool IsNinja() const { return false; }
|
||||
|
||||
/** Return true if we know the exact location of object files.
|
||||
If false, store the reason in the given string.
|
||||
This is meaningful only after EnableLanguage has been called. */
|
||||
virtual bool HasKnownObjectFileLocation(std::string*) const { return true; }
|
||||
/** Return true if we know the exact location of object files for the given
|
||||
cmTarget. If false, store the reason in the given string. This is
|
||||
meaningful only after EnableLanguage has been called. */
|
||||
virtual bool HasKnownObjectFileLocation(cmTarget const&, std::string*) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool UseFolderProperty() const;
|
||||
|
||||
|
@ -4924,7 +4924,7 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() const
|
||||
}
|
||||
|
||||
bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation(
|
||||
std::string* reason) const
|
||||
cmTarget const&, std::string* reason) const
|
||||
{
|
||||
if (this->ObjectDirArch.find('$') != std::string::npos) {
|
||||
if (reason != nullptr) {
|
||||
|
@ -107,7 +107,8 @@ public:
|
||||
|
||||
bool IsXcode() const override { return true; }
|
||||
|
||||
bool HasKnownObjectFileLocation(std::string* reason) const override;
|
||||
bool HasKnownObjectFileLocation(cmTarget const&,
|
||||
std::string* reason) const override;
|
||||
|
||||
bool IsIPOSupported() const override { return true; }
|
||||
|
||||
|
@ -919,8 +919,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
|
||||
if (!objectArgs.GetDestination().empty()) {
|
||||
// Verify that we know where the objects are to install them.
|
||||
std::string reason;
|
||||
if (!helper.Makefile->GetGlobalGenerator()
|
||||
->HasKnownObjectFileLocation(&reason)) {
|
||||
if (!target.HasKnownObjectFileLocation(&reason)) {
|
||||
status.SetError(
|
||||
cmStrCat("TARGETS given OBJECT library \"", target.GetName(),
|
||||
"\" whose objects may not be installed", reason, "."));
|
||||
|
@ -691,6 +691,11 @@ bool cmTarget::IsAndroidGuiExecutable() const
|
||||
this->impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI"));
|
||||
}
|
||||
|
||||
bool cmTarget::HasKnownObjectFileLocation(std::string* reason) const
|
||||
{
|
||||
return this->GetGlobalGenerator()->HasKnownObjectFileLocation(*this, reason);
|
||||
}
|
||||
|
||||
std::vector<cmCustomCommand> const& cmTarget::GetPreBuildCommands() const
|
||||
{
|
||||
return this->impl->PreBuildCommands;
|
||||
|
@ -220,6 +220,8 @@ public:
|
||||
//! Return whether this target is a GUI executable on Android.
|
||||
bool IsAndroidGuiExecutable() const;
|
||||
|
||||
bool HasKnownObjectFileLocation(std::string* reason = nullptr) const;
|
||||
|
||||
//! Get a backtrace from the creation of the target.
|
||||
cmListFileBacktrace const& GetBacktrace() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user