mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 03:29:18 -05:00
cmTargetPropertyComputer::GetProperty: return cmProp
This commit is contained in:
@@ -52,11 +52,11 @@
|
|||||||
class cmMessenger;
|
class cmMessenger;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
|
cmProp cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
|
||||||
cmGeneratorTarget const* tgt, cmMessenger* /* messenger */,
|
cmGeneratorTarget const* tgt, cmMessenger* /* messenger */,
|
||||||
cmListFileBacktrace const& /* context */)
|
cmListFileBacktrace const& /* context */)
|
||||||
{
|
{
|
||||||
return tgt->GetSourcesProperty().c_str();
|
return &tgt->GetSourcesProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@@ -376,9 +376,9 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
|
|||||||
this->GetBacktrace())) {
|
this->GetBacktrace())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (const char* result = cmTargetPropertyComputer::GetProperty(
|
if (cmProp result = cmTargetPropertyComputer::GetProperty(
|
||||||
this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
|
this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
|
||||||
return result;
|
return result->c_str();
|
||||||
}
|
}
|
||||||
if (cmSystemTools::GetFatalErrorOccured()) {
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
+5
-3
@@ -78,7 +78,7 @@ const std::string& cmTargetPropertyComputer::ComputeLocation<cmTarget>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
const char* cmTargetPropertyComputer::GetSources<cmTarget>(
|
cmProp cmTargetPropertyComputer::GetSources<cmTarget>(
|
||||||
cmTarget const* tgt, cmMessenger* messenger,
|
cmTarget const* tgt, cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context)
|
cmListFileBacktrace const& context)
|
||||||
{
|
{
|
||||||
@@ -156,7 +156,7 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
|
|||||||
}
|
}
|
||||||
static std::string srcs;
|
static std::string srcs;
|
||||||
srcs = ss.str();
|
srcs = ss.str();
|
||||||
return srcs.c_str();
|
return &srcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
class cmTargetInternals
|
class cmTargetInternals
|
||||||
@@ -1613,7 +1613,9 @@ const char* cmTarget::GetComputedProperty(
|
|||||||
const std::string& prop, cmMessenger* messenger,
|
const std::string& prop, cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context) const
|
cmListFileBacktrace const& context) const
|
||||||
{
|
{
|
||||||
return cmTargetPropertyComputer::GetProperty(this, prop, messenger, context);
|
cmProp retVal =
|
||||||
|
cmTargetPropertyComputer::GetProperty(this, prop, messenger, context);
|
||||||
|
return retVal ? retVal->c_str() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmTarget::GetProperty(const std::string& prop) const
|
const char* cmTarget::GetProperty(const std::string& prop) const
|
||||||
|
|||||||
@@ -14,15 +14,17 @@
|
|||||||
|
|
||||||
class cmMessenger;
|
class cmMessenger;
|
||||||
|
|
||||||
|
using cmProp = const std::string*;
|
||||||
|
|
||||||
class cmTargetPropertyComputer
|
class cmTargetPropertyComputer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
static const char* GetProperty(Target const* tgt, const std::string& prop,
|
static cmProp GetProperty(Target const* tgt, const std::string& prop,
|
||||||
cmMessenger* messenger,
|
cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context)
|
cmListFileBacktrace const& context)
|
||||||
{
|
{
|
||||||
if (const char* loc = GetLocation(tgt, prop, messenger, context)) {
|
if (cmProp loc = GetLocation(tgt, prop, messenger, context)) {
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
if (cmSystemTools::GetFatalErrorOccured()) {
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
||||||
@@ -52,9 +54,9 @@ private:
|
|||||||
std::string const& config);
|
std::string const& config);
|
||||||
|
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
static const char* GetLocation(Target const* tgt, std::string const& prop,
|
static cmProp GetLocation(Target const* tgt, std::string const& prop,
|
||||||
cmMessenger* messenger,
|
cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context)
|
cmListFileBacktrace const& context)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Watch for special "computed" properties that are dependent on
|
// Watch for special "computed" properties that are dependent on
|
||||||
@@ -71,7 +73,7 @@ private:
|
|||||||
context)) {
|
context)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ComputeLocationForBuild(tgt).c_str();
|
return &ComputeLocationForBuild(tgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support "LOCATION_<CONFIG>".
|
// Support "LOCATION_<CONFIG>".
|
||||||
@@ -82,7 +84,7 @@ private:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::string configName = prop.substr(9);
|
std::string configName = prop.substr(9);
|
||||||
return ComputeLocation(tgt, configName).c_str();
|
return &ComputeLocation(tgt, configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support "<CONFIG>_LOCATION".
|
// Support "<CONFIG>_LOCATION".
|
||||||
@@ -95,7 +97,7 @@ private:
|
|||||||
context)) {
|
context)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ComputeLocation(tgt, configName).c_str();
|
return &ComputeLocation(tgt, configName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,8 +105,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
static const char* GetSources(Target const* tgt, cmMessenger* messenger,
|
static cmProp GetSources(Target const* tgt, cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context);
|
cmListFileBacktrace const& context);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user