diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-02-12 10:29:09 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-02-13 14:12:30 (GMT) |
commit | a1c4905f723f9d99bd481580f9fe24fdaf81b174 (patch) | |
tree | 7e99ae5614cf070ae73a3607f8d1ce51e0c5ac79 /Source/cmGeneratorExpressionEvaluator.cxx | |
parent | 5c9f5e313ff893a28f975749ad9a6b19481e8e62 (diff) | |
download | CMake-a1c4905f723f9d99bd481580f9fe24fdaf81b174.zip CMake-a1c4905f723f9d99bd481580f9fe24fdaf81b174.tar.gz CMake-a1c4905f723f9d99bd481580f9fe24fdaf81b174.tar.bz2 |
Use the link information as a source of compile definitions and includes.
After evaluating the INTERFACE_INCLUDE_DIRECTORIES, of a target in a
generator expression, also read the INTERFACE_INCLUDE_DIRECTORIES of
its link interface dependencies.
That means that code such as this will result in the 'user' target
using /bar/include and /foo/include:
add_library(foo ...)
target_include_directories(foo INTERFACE /foo/include)
add_library(bar ...)
target_include_directories(bar INTERFACE /bar/include)
target_link_libraries(bar LINK_PUBLIC foo)
add_executable(user ...)
target_include_directories(user PRIVATE
$<TARGET_PROPERTY:bar,INTERFACE_INCLUDE_DIRECTORIES>)
Also process the interface include directories from direct link
dependencies for in-build targets.
The situation is similar for the INTERFACE_COMPILE_DEFINITIONS. The
include directories related code is currently more complex because
we also need to store a backtrace at configure-time for the purpose
of debugging includes. The compile definitions related code will use
the same pattern in the future.
This is not a change in behavior, as existing code has the same effect,
but that existing code will be removed in follow-up commits.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 69 |
1 files changed, 63 insertions, 6 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 98e0ada..6c1c12a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -451,15 +451,68 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } const char *prop = target->GetProperty(propertyName.c_str()); - if (!prop) + + std::string linkedTargetsContent; + + if (dagCheckerParent) { - if (target->IsImported()) + if (dagCheckerParent->EvaluatingLinkLibraries()) { - return std::string(); + if(!prop) + { + return std::string(); + } } - if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) + else { - return std::string(); + assert(dagCheckerParent->EvaluatingIncludeDirectories() + || dagCheckerParent->EvaluatingCompileDefinitions()); + + if (propertyName == "INTERFACE_INCLUDE_DIRECTORIES" + || propertyName == "INTERFACE_COMPILE_DEFINITIONS") + { + const cmTarget::LinkInterface *iface = target->GetLinkInterface( + context->Config, + context->HeadTarget); + if(iface) + { + cmGeneratorExpression ge(context->Backtrace); + + std::string sep; + std::string depString; + for (std::vector<std::string>::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + if (context->Makefile->FindTargetToUse(it->c_str())) + { + depString += + sep + "$<TARGET_PROPERTY:" + *it + "," + propertyName + ">"; + sep = ";"; + } + } + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(depString); + linkedTargetsContent = cge->Evaluate(context->Makefile, + context->Config, + context->Quiet, + context->HeadTarget, + target, + &dagChecker); + if (cge->GetHadContextSensitiveCondition()) + { + context->HadContextSensitiveCondition = true; + } + } + } + } + } + + if (!prop) + { + if (target->IsImported()) + { + return linkedTargetsContent; } if (target->IsLinkInterfaceDependentBoolProperty(propertyName, context->Config)) @@ -480,7 +533,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode return propContent ? propContent : ""; } - return std::string(); + return linkedTargetsContent; } for (size_t i = 0; @@ -503,6 +556,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; } + if (!linkedTargetsContent.empty()) + { + result += (result.empty() ? "" : ";") + linkedTargetsContent; + } return result; } } |