Commit 4025013d authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'compatible-interface-numbers'

ff6c4013 cmTarget: Add interface for compatible numeric properties
e4e20c1d cmTarget: Add enumeration for consistency to expect from properties.
98777694 cmTarget: Assign consistent content back to the property being evaluated.
816b4a8a cmTarget: Make consistentProperty return consistent content.
030800a7 cmTarget: Add a template to create correct implied content.
parents 5f789db8 ff6c4013
......@@ -76,6 +76,8 @@ Properties on Targets
/prop_tgt/BUNDLE_EXTENSION
/prop_tgt/BUNDLE
/prop_tgt/COMPATIBLE_INTERFACE_BOOL
/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX
/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN
/prop_tgt/COMPATIBLE_INTERFACE_STRING
/prop_tgt/COMPILE_DEFINITIONS_CONFIG
/prop_tgt/COMPILE_DEFINITIONS
......
......@@ -14,4 +14,6 @@ property is set, then it must have the same boolean value as all
others, and if the property is not set, then it is ignored. Note that
for each dependee, the set of properties from this property must not
intersect with the set of properties from the
COMPATIBLE_INTERFACE_STRING property.
:prop_tgt:`COMPATIBLE_INTERFACE_STRING`,
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` or
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property.
COMPATIBLE_INTERFACE_NUMBER_MAX
-------------------------------
Properties whose maximum value from the link interface will be used.
The COMPATIBLE_INTERFACE_NUMBER_MAX property may contain a list of
properties for this target whose maximum value may be read at generate time
when evaluated in the INTERFACE of all linked dependees. For example, if a
property "FOO" appears in the list, then for each dependee, the
"INTERFACE_FOO" property content in all of its dependencies will be compared
with each other and with the "FOO" property in the depender. When reading
the FOO property at generate time, the maximum value will be returned.
If the property is not set, then it is ignored. Note that for each
dependee, the set of properties from this property must not intersect
with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`,
:prop_tgt:`COMPATIBLE_INTERFACE_STRING` or
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` property.
COMPATIBLE_INTERFACE_NUMBER_MIN
-------------------------------
Properties whose maximum value from the link interface will be used.
The COMPATIBLE_INTERFACE_NUMBER_MIN property may contain a list of
properties for this target whose minimum value may be read at generate time
when evaluated in the INTERFACE of all linked dependees. For example, if a
property "FOO" appears in the list, then for each dependee, the
"INTERFACE_FOO" property content in all of its dependencies will be compared
with each other and with the "FOO" property in the depender. When reading
the FOO property at generate time, the minimum value will be returned.
If the property is not set, then it is ignored. Note that for each
dependee, the set of properties from this property must not intersect
with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`,
:prop_tgt:`COMPATIBLE_INTERFACE_STRING` or
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property.
......@@ -11,5 +11,6 @@ property "FOO" appears in the list, then for each dependee, the
equal with each other, and with the "FOO" property in the depender.
If the property is not set, then it is ignored. Note that for each
dependee, the set of properties from this property must not intersect
with the set of properties from the COMPATIBLE_INTERFACE_BOOL
property.
with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`,
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` or
:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property.
......@@ -411,6 +411,12 @@ void getCompatibleInterfaceProperties(cmTarget *target,
getPropertyContents(li->Target,
"COMPATIBLE_INTERFACE_STRING",
ifaceProperties);
getPropertyContents(li->Target,
"COMPATIBLE_INTERFACE_NUMBER_MIN",
ifaceProperties);
getPropertyContents(li->Target,
"COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
}
}
......@@ -423,11 +429,19 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
target, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
target, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
target, properties);
this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
target, properties);
std::set<std::string> ifaceProperties;
getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
ifaceProperties);
getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
getCompatibleInterfaceProperties(target, ifaceProperties, 0);
......
......@@ -980,10 +980,54 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
target->GetLinkInterfaceDependentNumberMinProperty(
propertyName,
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
target->GetLinkInterfaceDependentNumberMaxProperty(
propertyName,
context->Config);
return propContent ? propContent : "";
}
return linkedTargetsContent;
}
if (!target->IsImported()
&& dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
{
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
target->GetLinkInterfaceDependentNumberMinProperty(
propertyName,
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
target->GetLinkInterfaceDependentNumberMaxProperty(
propertyName,
context->Config);
return propContent ? propContent : "";
}
}
for (size_t i = 1;
i < cmArraySize(targetPropertyTransitiveWhitelist);
++i)
......
This diff is collapsed.
......@@ -536,12 +536,20 @@ public:
const char *config);
bool IsLinkInterfaceDependentStringProperty(const std::string &p,
const char *config);
bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
const char *config);
bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const char *config);
bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
const char *config);
const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
const char *config);
const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
const char *config);
const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const char *config);
std::string GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt);
......
......@@ -20,11 +20,25 @@ set_property(TARGET iface1 APPEND PROPERTY
STRING_PROP2
STRING_PROP3
)
set_property(TARGET iface1 APPEND PROPERTY
COMPATIBLE_INTERFACE_NUMBER_MIN
NUMBER_MIN_PROP1
NUMBER_MIN_PROP2
)
set_property(TARGET iface1 APPEND PROPERTY
COMPATIBLE_INTERFACE_NUMBER_MAX
NUMBER_MAX_PROP1
NUMBER_MAX_PROP2
)
set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON)
set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON)
set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1)
set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2)
set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP1 100)
set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP2 200)
set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP1 100)
set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP2 200)
add_executable(CompatibleInterface main.cpp)
target_link_libraries(CompatibleInterface iface1)
......@@ -33,6 +47,10 @@ set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON)
set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON)
set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2)
set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3)
set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP1 50)
set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP2 250)
set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP1 50)
set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP2 250)
target_compile_definitions(CompatibleInterface
PRIVATE
......@@ -42,6 +60,10 @@ target_compile_definitions(CompatibleInterface
$<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP1>,prop1>:STRING_PROP1>
$<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP2>,prop2>:STRING_PROP2>
$<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP3>,prop3>:STRING_PROP3>
$<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP1>,50>:NUMBER_MIN_PROP1=50>
$<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP2>,200>:NUMBER_MIN_PROP2=200>
$<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP1>,100>:NUMBER_MAX_PROP1=100>
$<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP2>,250>:NUMBER_MAX_PROP2=250>
)
......
......@@ -23,6 +23,19 @@
#error Expected STRING_PROP3
#endif
template<bool test>
struct CMakeStaticAssert;
template<>
struct CMakeStaticAssert<true> {};
enum {
NumericMaxTest1 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP1 == 100>),
NumericMaxTest2 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP2 == 250>),
NumericMinTest1 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP1 == 50>),
NumericMinTest2 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP2 == 200>)
};
#include "iface2.h"
int main(int argc, char **argv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment