mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-30 02:59:22 -05:00
cmStateDirectory::GetProperty: return cmProp
This commit is contained in:
@@ -2965,8 +2965,8 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature,
|
|||||||
}
|
}
|
||||||
cmStateSnapshot snp = this->StateSnapshot;
|
cmStateSnapshot snp = this->StateSnapshot;
|
||||||
while (snp.IsValid()) {
|
while (snp.IsValid()) {
|
||||||
if (const char* value = snp.GetDirectory().GetProperty(featureName)) {
|
if (cmProp value = snp.GetDirectory().GetProperty(featureName)) {
|
||||||
return value;
|
return value->c_str();
|
||||||
}
|
}
|
||||||
snp = snp.GetBuildsystemDirectoryParent();
|
snp = snp.GetBuildsystemDirectoryParent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4102,12 +4102,14 @@ const char* cmMakefile::GetProperty(const std::string& prop) const
|
|||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->StateSnapshot.GetDirectory().GetProperty(prop);
|
cmProp retVal = this->StateSnapshot.GetDirectory().GetProperty(prop);
|
||||||
|
return retVal ? retVal->c_str() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
|
const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
|
||||||
{
|
{
|
||||||
return this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
|
cmProp retVal = this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
|
||||||
|
return retVal ? retVal->c_str() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
|
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
|
||||||
|
|||||||
+20
-20
@@ -548,32 +548,31 @@ void cmStateDirectory::AppendProperty(const std::string& prop,
|
|||||||
this->DirectoryState->Properties.AppendProperty(prop, value, asString);
|
this->DirectoryState->Properties.AppendProperty(prop, value, asString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmStateDirectory::GetProperty(const std::string& prop) const
|
cmProp cmStateDirectory::GetProperty(const std::string& prop) const
|
||||||
{
|
{
|
||||||
const bool chain =
|
const bool chain =
|
||||||
this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY);
|
this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY);
|
||||||
return this->GetProperty(prop, chain);
|
return this->GetProperty(prop, chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmStateDirectory::GetProperty(const std::string& prop,
|
cmProp cmStateDirectory::GetProperty(const std::string& prop, bool chain) const
|
||||||
bool chain) const
|
|
||||||
{
|
{
|
||||||
static std::string output;
|
static std::string output;
|
||||||
output.clear();
|
output.clear();
|
||||||
if (prop == "PARENT_DIRECTORY") {
|
if (prop == "PARENT_DIRECTORY") {
|
||||||
cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
|
cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
|
||||||
if (parent.IsValid()) {
|
if (parent.IsValid()) {
|
||||||
return parent.GetDirectory().GetCurrentSource().c_str();
|
return &parent.GetDirectory().GetCurrentSource();
|
||||||
}
|
}
|
||||||
return "";
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == kBINARY_DIR) {
|
if (prop == kBINARY_DIR) {
|
||||||
output = this->GetCurrentBinary();
|
output = this->GetCurrentBinary();
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == kSOURCE_DIR) {
|
if (prop == kSOURCE_DIR) {
|
||||||
output = this->GetCurrentSource();
|
output = this->GetCurrentSource();
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == kSUBDIRECTORIES) {
|
if (prop == kSUBDIRECTORIES) {
|
||||||
std::vector<std::string> child_dirs;
|
std::vector<std::string> child_dirs;
|
||||||
@@ -584,11 +583,11 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
|
|||||||
child_dirs.push_back(ci.GetDirectory().GetCurrentSource());
|
child_dirs.push_back(ci.GetDirectory().GetCurrentSource());
|
||||||
}
|
}
|
||||||
output = cmJoin(child_dirs, ";");
|
output = cmJoin(child_dirs, ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == kBUILDSYSTEM_TARGETS) {
|
if (prop == kBUILDSYSTEM_TARGETS) {
|
||||||
output = cmJoin(this->DirectoryState->NormalTargetNames, ";");
|
output = cmJoin(this->DirectoryState->NormalTargetNames, ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop == "LISTFILE_STACK") {
|
if (prop == "LISTFILE_STACK") {
|
||||||
@@ -600,38 +599,38 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
|
|||||||
}
|
}
|
||||||
std::reverse(listFiles.begin(), listFiles.end());
|
std::reverse(listFiles.begin(), listFiles.end());
|
||||||
output = cmJoin(listFiles, ";");
|
output = cmJoin(listFiles, ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "CACHE_VARIABLES") {
|
if (prop == "CACHE_VARIABLES") {
|
||||||
output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
|
output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "VARIABLES") {
|
if (prop == "VARIABLES") {
|
||||||
std::vector<std::string> res = this->Snapshot_.ClosureKeys();
|
std::vector<std::string> res = this->Snapshot_.ClosureKeys();
|
||||||
cm::append(res, this->Snapshot_.State->GetCacheEntryKeys());
|
cm::append(res, this->Snapshot_.State->GetCacheEntryKeys());
|
||||||
std::sort(res.begin(), res.end());
|
std::sort(res.begin(), res.end());
|
||||||
output = cmJoin(res, ";");
|
output = cmJoin(res, ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "INCLUDE_DIRECTORIES") {
|
if (prop == "INCLUDE_DIRECTORIES") {
|
||||||
output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
|
output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "COMPILE_OPTIONS") {
|
if (prop == "COMPILE_OPTIONS") {
|
||||||
output = cmJoin(this->GetCompileOptionsEntries(), ";");
|
output = cmJoin(this->GetCompileOptionsEntries(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "COMPILE_DEFINITIONS") {
|
if (prop == "COMPILE_DEFINITIONS") {
|
||||||
output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
|
output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "LINK_OPTIONS") {
|
if (prop == "LINK_OPTIONS") {
|
||||||
output = cmJoin(this->GetLinkOptionsEntries(), ";");
|
output = cmJoin(this->GetLinkOptionsEntries(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
if (prop == "LINK_DIRECTORIES") {
|
if (prop == "LINK_DIRECTORIES") {
|
||||||
output = cmJoin(this->GetLinkDirectoriesEntries(), ";");
|
output = cmJoin(this->GetLinkDirectoriesEntries(), ";");
|
||||||
return output.c_str();
|
return &output;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmProp retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
|
cmProp retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
|
||||||
@@ -641,15 +640,16 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
|
|||||||
if (parentSnapshot.IsValid()) {
|
if (parentSnapshot.IsValid()) {
|
||||||
return parentSnapshot.GetDirectory().GetProperty(prop, chain);
|
return parentSnapshot.GetDirectory().GetProperty(prop, chain);
|
||||||
}
|
}
|
||||||
retVal = this->Snapshot_.State->GetGlobalProperty(prop);
|
return this->Snapshot_.State->GetGlobalProperty(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal ? retVal->c_str() : nullptr;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
|
bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
|
||||||
{
|
{
|
||||||
return cmIsOn(this->GetProperty(prop));
|
cmProp p = this->GetProperty(prop);
|
||||||
|
return p && cmIsOn(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
|
std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "cmStateSnapshot.h"
|
#include "cmStateSnapshot.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
|
|
||||||
|
using cmProp = const std::string*;
|
||||||
|
|
||||||
class cmStateDirectory
|
class cmStateDirectory
|
||||||
{
|
{
|
||||||
cmStateDirectory(
|
cmStateDirectory(
|
||||||
@@ -86,8 +88,8 @@ public:
|
|||||||
cmListFileBacktrace const& lfbt);
|
cmListFileBacktrace const& lfbt);
|
||||||
void AppendProperty(const std::string& prop, const std::string& value,
|
void AppendProperty(const std::string& prop, const std::string& value,
|
||||||
bool asString, cmListFileBacktrace const& lfbt);
|
bool asString, cmListFileBacktrace const& lfbt);
|
||||||
const char* GetProperty(const std::string& prop) const;
|
cmProp GetProperty(const std::string& prop) const;
|
||||||
const char* GetProperty(const std::string& prop, bool chain) const;
|
cmProp GetProperty(const std::string& prop, bool chain) const;
|
||||||
bool GetPropertyAsBool(const std::string& prop) const;
|
bool GetPropertyAsBool(const std::string& prop) const;
|
||||||
std::vector<std::string> GetPropertyKeys() const;
|
std::vector<std::string> GetPropertyKeys() const;
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -1779,8 +1779,11 @@ const char* cmTarget::GetProperty(const std::string& prop) const
|
|||||||
const bool chain =
|
const bool chain =
|
||||||
impl->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TARGET);
|
impl->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TARGET);
|
||||||
if (chain) {
|
if (chain) {
|
||||||
return impl->Makefile->GetStateSnapshot().GetDirectory().GetProperty(
|
retVal = impl->Makefile->GetStateSnapshot().GetDirectory().GetProperty(
|
||||||
prop, chain);
|
prop, chain);
|
||||||
|
if (retVal) {
|
||||||
|
return retVal->c_str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user