Use a preprocessor loop to manage the valid transitive properties.
Hopefully this will prevent regressions when adding further transitive properties in the future.
This commit is contained in:
parent
8a3b5bede8
commit
0d8db250ce
|
@ -31,9 +31,10 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
|
||||||
|
|
||||||
ImportPropertyMap properties;
|
ImportPropertyMap properties;
|
||||||
|
|
||||||
this->FindTargets("INTERFACE_INCLUDE_DIRECTORIES", te, emittedDeps);
|
#define FIND_TARGETS(PROPERTY) \
|
||||||
this->FindTargets("INTERFACE_COMPILE_DEFINITIONS", te, emittedDeps);
|
this->FindTargets(#PROPERTY, te, emittedDeps);
|
||||||
this->FindTargets("INTERFACE_COMPILE_OPTIONS", te, emittedDeps);
|
|
||||||
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
|
||||||
|
|
||||||
this->PopulateProperties(te, properties, emittedDeps);
|
this->PopulateProperties(te, properties, emittedDeps);
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,13 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
|
||||||
}
|
}
|
||||||
this->CheckResult = this->checkGraph();
|
this->CheckResult = this->checkGraph();
|
||||||
|
|
||||||
if (CheckResult == DAG && (top->EvaluatingIncludeDirectories()
|
#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
||||||
|| top->EvaluatingCompileDefinitions()
|
top->METHOD () ||
|
||||||
|| top->EvaluatingCompileOptions()))
|
|
||||||
|
if (CheckResult == DAG && (
|
||||||
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(TEST_TRANSITIVE_PROPERTY_METHOD)
|
||||||
|
false)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
std::map<cmStdString, std::set<cmStdString> >::const_iterator it
|
std::map<cmStdString, std::set<cmStdString> >::const_iterator it
|
||||||
= top->Seen.find(target);
|
= top->Seen.find(target);
|
||||||
|
|
|
@ -16,6 +16,16 @@
|
||||||
|
|
||||||
#include "cmGeneratorExpressionEvaluator.h"
|
#include "cmGeneratorExpressionEvaluator.h"
|
||||||
|
|
||||||
|
#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \
|
||||||
|
F(EvaluatingIncludeDirectories) \
|
||||||
|
F(EvaluatingCompileDefinitions) \
|
||||||
|
F(EvaluatingCompileOptions)
|
||||||
|
|
||||||
|
#define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \
|
||||||
|
F(INTERFACE_INCLUDE_DIRECTORIES) \
|
||||||
|
F(INTERFACE_COMPILE_DEFINITIONS) \
|
||||||
|
F(INTERFACE_COMPILE_OPTIONS)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
struct cmGeneratorExpressionDAGChecker
|
struct cmGeneratorExpressionDAGChecker
|
||||||
{
|
{
|
||||||
|
@ -38,9 +48,11 @@ struct cmGeneratorExpressionDAGChecker
|
||||||
const std::string &expr);
|
const std::string &expr);
|
||||||
|
|
||||||
bool EvaluatingLinkLibraries();
|
bool EvaluatingLinkLibraries();
|
||||||
bool EvaluatingIncludeDirectories() const;
|
|
||||||
bool EvaluatingCompileDefinitions() const;
|
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
||||||
bool EvaluatingCompileOptions() const;
|
bool METHOD () const;
|
||||||
|
|
||||||
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Result checkGraph() const;
|
Result checkGraph() const;
|
||||||
|
|
|
@ -491,11 +491,13 @@ static const struct JoinNode : public cmGeneratorExpressionNode
|
||||||
}
|
}
|
||||||
} joinNode;
|
} joinNode;
|
||||||
|
|
||||||
|
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
|
||||||
|
, #PROPERTY
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static const char* targetPropertyTransitiveWhitelist[] = {
|
static const char* targetPropertyTransitiveWhitelist[] = {
|
||||||
"INTERFACE_INCLUDE_DIRECTORIES"
|
0
|
||||||
, "INTERFACE_COMPILE_DEFINITIONS"
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
|
||||||
, "INTERFACE_COMPILE_OPTIONS"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
||||||
|
@ -675,7 +677,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
// No error. We just skip cyclic references.
|
// No error. We just skip cyclic references.
|
||||||
return std::string();
|
return std::string();
|
||||||
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
|
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
|
||||||
for (size_t i = 0;
|
for (size_t i = 1;
|
||||||
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
||||||
sizeof(*targetPropertyTransitiveWhitelist));
|
sizeof(*targetPropertyTransitiveWhitelist));
|
||||||
++i)
|
++i)
|
||||||
|
@ -703,9 +705,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(dagCheckerParent->EvaluatingIncludeDirectories()
|
#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
||||||
|| dagCheckerParent->EvaluatingCompileDefinitions()
|
dagCheckerParent->METHOD () ||
|
||||||
|| dagCheckerParent->EvaluatingCompileOptions());
|
|
||||||
|
assert(
|
||||||
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
|
||||||
|
ASSERT_TRANSITIVE_PROPERTY_METHOD)
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +738,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
|
|
||||||
cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
|
cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
|
||||||
|
|
||||||
const char **transBegin = targetPropertyTransitiveWhitelist;
|
const char **transBegin = targetPropertyTransitiveWhitelist + 1;
|
||||||
const char **transEnd = targetPropertyTransitiveWhitelist
|
const char **transEnd = targetPropertyTransitiveWhitelist
|
||||||
+ (sizeof(targetPropertyTransitiveWhitelist) /
|
+ (sizeof(targetPropertyTransitiveWhitelist) /
|
||||||
sizeof(*targetPropertyTransitiveWhitelist));
|
sizeof(*targetPropertyTransitiveWhitelist));
|
||||||
|
@ -798,7 +804,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
return linkedTargetsContent;
|
return linkedTargetsContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0;
|
for (size_t i = 1;
|
||||||
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
||||||
sizeof(*targetPropertyTransitiveWhitelist));
|
sizeof(*targetPropertyTransitiveWhitelist));
|
||||||
++i)
|
++i)
|
||||||
|
|
Loading…
Reference in New Issue