mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
cmTargetPropertyComputer: Move whitelist check from cmTarget
This commit is contained in:
@@ -707,38 +707,10 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const
|
|||||||
return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces);
|
return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool whiteListedInterfaceProperty(const std::string& prop)
|
|
||||||
{
|
|
||||||
if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
static UNORDERED_SET<std::string> builtIns;
|
|
||||||
if (builtIns.empty()) {
|
|
||||||
builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
|
|
||||||
builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX");
|
|
||||||
builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MIN");
|
|
||||||
builtIns.insert("COMPATIBLE_INTERFACE_STRING");
|
|
||||||
builtIns.insert("EXPORT_NAME");
|
|
||||||
builtIns.insert("IMPORTED");
|
|
||||||
builtIns.insert("NAME");
|
|
||||||
builtIns.insert("TYPE");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (builtIns.count(prop)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmTarget::SetProperty(const std::string& prop, const char* value)
|
void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
{
|
{
|
||||||
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
||||||
!whiteListedInterfaceProperty(prop)) {
|
!cmTargetPropertyComputer::WhiteListedInterfaceProperty(prop)) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
||||||
"The property \""
|
"The property \""
|
||||||
@@ -822,7 +794,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
|
|||||||
bool asString)
|
bool asString)
|
||||||
{
|
{
|
||||||
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
||||||
!whiteListedInterfaceProperty(prop)) {
|
!cmTargetPropertyComputer::WhiteListedInterfaceProperty(prop)) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
||||||
"The property \""
|
"The property \""
|
||||||
@@ -1041,7 +1013,7 @@ const char* cmTarget::GetProperty(const std::string& prop,
|
|||||||
cmMakefile* context) const
|
cmMakefile* context) const
|
||||||
{
|
{
|
||||||
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
if (this->GetType() == cmState::INTERFACE_LIBRARY &&
|
||||||
!whiteListedInterfaceProperty(prop)) {
|
!cmTargetPropertyComputer::WhiteListedInterfaceProperty(prop)) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
|
||||||
"The property \""
|
"The property \""
|
||||||
|
@@ -154,7 +154,7 @@ const char* cmTargetPropertyComputer::GetLocation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* cmTargetPropertyComputer::GetSources(
|
const char* cmTargetPropertyComputer::GetSources(
|
||||||
cmTarget const* tgt,cmMessenger* messenger,
|
cmTarget const* tgt, cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context)
|
cmListFileBacktrace const& context)
|
||||||
{
|
{
|
||||||
cmStringRange entries = tgt->GetSourceEntries();
|
cmStringRange entries = tgt->GetSourceEntries();
|
||||||
@@ -241,3 +241,32 @@ const char* cmTargetPropertyComputer::GetSources(
|
|||||||
srcs = ss.str();
|
srcs = ss.str();
|
||||||
return srcs.c_str();
|
return srcs.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
|
||||||
|
const std::string& prop)
|
||||||
|
{
|
||||||
|
if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
static UNORDERED_SET<std::string> builtIns;
|
||||||
|
if (builtIns.empty()) {
|
||||||
|
builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
|
||||||
|
builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX");
|
||||||
|
builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MIN");
|
||||||
|
builtIns.insert("COMPATIBLE_INTERFACE_STRING");
|
||||||
|
builtIns.insert("EXPORT_NAME");
|
||||||
|
builtIns.insert("IMPORTED");
|
||||||
|
builtIns.insert("NAME");
|
||||||
|
builtIns.insert("TYPE");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (builtIns.count(prop)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@@ -23,6 +23,8 @@ public:
|
|||||||
static std::map<std::string, std::string> ComputeFileLocations(
|
static std::map<std::string, std::string> ComputeFileLocations(
|
||||||
cmTarget const* tgt);
|
cmTarget const* tgt);
|
||||||
|
|
||||||
|
static bool WhiteListedInterfaceProperty(const std::string& prop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool HandleLocationPropertyPolicy(std::string const& tgtName,
|
static bool HandleLocationPropertyPolicy(std::string const& tgtName,
|
||||||
cmMessenger* messenger,
|
cmMessenger* messenger,
|
||||||
@@ -35,9 +37,8 @@ private:
|
|||||||
cmMessenger* messenger,
|
cmMessenger* messenger,
|
||||||
cmListFileBacktrace const& context);
|
cmListFileBacktrace const& context);
|
||||||
|
|
||||||
static const char* GetSources(cmTarget const* tgt,
|
static const char* GetSources(cmTarget const* tgt, cmMessenger* messenger,
|
||||||
cmMessenger* messenger,
|
cmListFileBacktrace const& context);
|
||||||
cmListFileBacktrace const& context);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user