Genex: Use a preprocessor loop to implement transitive DAG check.

The other infrastructure for transitive property handling is
already using a preprocessor loop.

Implement special backward-compatibility handling of
COMPILE_DEFINITIONS_<CONFIG> using a template switch for the
extra check.
This commit is contained in:
Stephen Kelly 2014-01-05 12:40:38 +01:00
parent 711fb38f72
commit 646c6ec2f9
2 changed files with 29 additions and 32 deletions

View File

@ -179,44 +179,37 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt)
|| strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
} }
//---------------------------------------------------------------------------- enum TransitiveProperty {
bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() const #define DEFINE_ENUM_ENTRY(NAME) NAME,
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY)
#undef DEFINE_ENUM_ENTRY
TransitivePropertyTerminal
};
template<TransitiveProperty>
bool additionalTest(const char* const)
{ {
const char *prop = this->Property.c_str(); return false;
return (strcmp(prop, "INCLUDE_DIRECTORIES") == 0
|| strcmp(prop, "INTERFACE_INCLUDE_DIRECTORIES") == 0 );
} }
//---------------------------------------------------------------------------- template<>
bool bool additionalTest<COMPILE_DEFINITIONS>(const char* const prop)
cmGeneratorExpressionDAGChecker::EvaluatingSystemIncludeDirectories() const
{ {
const char *prop = this->Property.c_str(); return cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_");
return (strcmp(prop, "SYSTEM_INCLUDE_DIRECTORIES") == 0
|| strcmp(prop, "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") == 0);
} }
//---------------------------------------------------------------------------- #define DEFINE_TRANSITIVE_PROPERTY_METHOD(METHOD, PROPERTY) \
bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const bool cmGeneratorExpressionDAGChecker::METHOD() const \
{ { \
const char *prop = this->Property.c_str(); const char* const prop = this->Property.c_str(); \
return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 if (strcmp(prop, #PROPERTY) == 0 \
|| strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 || strcmp(prop, "INTERFACE_" #PROPERTY) == 0) \
|| cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_")); { \
return true; \
} \
return additionalTest<PROPERTY>(prop); \
} }
//---------------------------------------------------------------------------- CM_FOR_EACH_TRANSITIVE_PROPERTY(DEFINE_TRANSITIVE_PROPERTY_METHOD)
bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const
{
const char *prop = this->Property.c_str();
return (strcmp(prop, "COMPILE_OPTIONS") == 0
|| strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 );
}
//---------------------------------------------------------------------------- #undef DEFINE_TRANSITIVE_PROPERTY_METHOD
bool cmGeneratorExpressionDAGChecker::EvaluatingAutoUicOptions() const
{
const char *prop = this->Property.c_str();
return (strcmp(prop, "AUTOUIC_OPTIONS") == 0
|| strcmp(prop, "INTERFACE_AUTOUIC_OPTIONS") == 0 );
}

View File

@ -16,6 +16,7 @@
#include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionEvaluator.h"
#define CM_SELECT_BOTH(F, A1, A2) F(A1, A2)
#define CM_SELECT_FIRST(F, A1, A2) F(A1) #define CM_SELECT_FIRST(F, A1, A2) F(A1)
#define CM_SELECT_SECOND(F, A1, A2) F(A2) #define CM_SELECT_SECOND(F, A1, A2) F(A2)
@ -26,6 +27,9 @@
SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \
SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ #define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \
CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST) CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST)