mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
Refactor: cmTest::GetProperty returns cmProp
This commit is contained in:
@@ -268,6 +268,11 @@ bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
const std::string& variable, cmProp value)
|
||||
{
|
||||
return StoreResult(infoType, makefile, variable, value.GetCStr());
|
||||
}
|
||||
|
||||
bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
|
||||
OutType infoType, const std::string& variable,
|
||||
@@ -280,9 +285,8 @@ bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
|
||||
|
||||
// Get the property.
|
||||
cmake* cm = status.GetMakefile().GetCMakeInstance();
|
||||
return StoreResult(
|
||||
infoType, status.GetMakefile(), variable,
|
||||
cmToCStr(cm->GetState()->GetGlobalProperty(propertyName)));
|
||||
return StoreResult(infoType, status.GetMakefile(), variable,
|
||||
cm->GetState()->GetGlobalProperty(propertyName));
|
||||
}
|
||||
|
||||
bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
|
||||
@@ -329,7 +333,7 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
|
||||
|
||||
// Get the property.
|
||||
return StoreResult(infoType, status.GetMakefile(), variable,
|
||||
cmToCStr(mf->GetProperty(propertyName)));
|
||||
mf->GetProperty(propertyName));
|
||||
}
|
||||
|
||||
bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
|
||||
@@ -365,8 +369,7 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
|
||||
if (!prop) {
|
||||
prop = target->GetProperty(propertyName);
|
||||
}
|
||||
return StoreResult(infoType, status.GetMakefile(), variable,
|
||||
cmToCStr(prop));
|
||||
return StoreResult(infoType, status.GetMakefile(), variable, prop);
|
||||
}
|
||||
status.SetError(cmStrCat("could not find TARGET ", name,
|
||||
". Perhaps it has not yet been created."));
|
||||
@@ -391,7 +394,7 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
|
||||
if (cmSourceFile* sf =
|
||||
directory_makefile.GetOrCreateSource(source_file_absolute_path)) {
|
||||
return StoreResult(infoType, status.GetMakefile(), variable,
|
||||
cmToCStr(sf->GetPropertyForUser(propertyName)));
|
||||
sf->GetPropertyForUser(propertyName));
|
||||
}
|
||||
status.SetError(
|
||||
cmStrCat("given SOURCE name that could not be found or created: ",
|
||||
@@ -447,7 +450,7 @@ bool HandleCacheMode(cmExecutionStatus& status, const std::string& name,
|
||||
value = status.GetMakefile().GetState()->GetCacheEntryProperty(
|
||||
name, propertyName);
|
||||
}
|
||||
StoreResult(infoType, status.GetMakefile(), variable, cmToCStr(value));
|
||||
StoreResult(infoType, status.GetMakefile(), variable, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmProperty.h"
|
||||
#include "cmTest.h"
|
||||
|
||||
bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
|
||||
@@ -19,12 +20,12 @@ bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
cmTest* test = mf.GetTest(testName);
|
||||
if (test) {
|
||||
const char* prop = nullptr;
|
||||
cmProp prop;
|
||||
if (!args[1].empty()) {
|
||||
prop = test->GetProperty(args[1]);
|
||||
}
|
||||
if (prop) {
|
||||
mf.AddDefinition(var, prop);
|
||||
mf.AddDefinition(var, prop->c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void cmTest::SetCommand(std::vector<std::string> const& command)
|
||||
this->Command = command;
|
||||
}
|
||||
|
||||
const char* cmTest::GetProperty(const std::string& prop) const
|
||||
cmProp cmTest::GetProperty(const std::string& prop) const
|
||||
{
|
||||
cmProp retVal = this->Properties.GetPropertyValue(prop);
|
||||
if (!retVal) {
|
||||
@@ -40,12 +40,12 @@ const char* cmTest::GetProperty(const std::string& prop) const
|
||||
this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
|
||||
if (chain) {
|
||||
if (cmProp p = this->Makefile->GetProperty(prop, chain)) {
|
||||
return p->c_str();
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
return retVal->c_str();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool cmTest::GetPropertyAsBool(const std::string& prop) const
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmProperty.h"
|
||||
#include "cmPropertyMap.h"
|
||||
|
||||
class cmMakefile;
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
void AppendProperty(const std::string& prop, const std::string& value,
|
||||
bool asString = false);
|
||||
const char* GetProperty(const std::string& prop) const;
|
||||
cmProp GetProperty(const std::string& prop) const;
|
||||
bool GetPropertyAsBool(const std::string& prop) const;
|
||||
cmPropertyMap& GetProperties() { return this->Properties; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user