summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyper Nova Sun <hypernovasun@icloud.com>2022-04-08 20:22:08 (GMT)
committerHyper Nova Sun <hypernovasun@icloud.com>2022-04-11 21:10:29 (GMT)
commit41ba35a42b177db14358390e50857eb2554a3873 (patch)
tree0f758fe4a2a5cb67a0f7c82b0521027b129da41b
parent7fc248bde34c529c6f1312a56c7e82303238b9c1 (diff)
downloadCMake-41ba35a42b177db14358390e50857eb2554a3873.zip
CMake-41ba35a42b177db14358390e50857eb2554a3873.tar.gz
CMake-41ba35a42b177db14358390e50857eb2554a3873.tar.bz2
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
-rw-r--r--Source/cmExportBuildFileGenerator.cxx2
-rw-r--r--Source/cmFileAPICodemodel.cxx2
-rw-r--r--Source/cmGeneratorExpressionNode.cxx2
-rw-r--r--Source/cmGlobalGenerator.h11
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmInstallCommand.cxx3
-rw-r--r--Source/cmTarget.cxx5
-rw-r--r--Source/cmTarget.h2
9 files changed, 21 insertions, 11 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index a47f1e5..c7e1f3c 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -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;
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 40e1d2e..dd0540c 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -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;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 3d1cfbf..a9bc435 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -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"
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 5965a16..dcef070 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -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;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 3ce3d59..29d7139 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -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) {
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 1159d1f..92e4528 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -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; }
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 1ed698d..7de2cb1 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -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, "."));
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e2314e2..f6952b5 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -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;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 0cdd2fc..edb49be 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -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;