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