diff options
author | Brad King <brad.king@kitware.com> | 2014-06-30 15:41:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-07 12:52:41 (GMT) |
commit | b5b098ebb39c97f3420eb7c24f0d4d5bc2d15a5a (patch) | |
tree | bdacd2be54e6f445847691e85e5768d240605091 /Source/cmTarget.cxx | |
parent | 5e07dcf7c8e884380e1ad5ab64ba3bcdef601eee (diff) | |
download | CMake-b5b098ebb39c97f3420eb7c24f0d4d5bc2d15a5a.zip CMake-b5b098ebb39c97f3420eb7c24f0d4d5bc2d15a5a.tar.gz CMake-b5b098ebb39c97f3420eb7c24f0d4d5bc2d15a5a.tar.bz2 |
cmTarget: Simplify CMP0027 logic in processIncludeDirectories
Evaluate and lookup the target name only once per TargetPropertyEntry
instead of repeating it for each include directory entry. Use a local
checkCMP0027 variable to record whether the policy should be checked.
Evaluate the target name as a generator expression only if it looks like
one. Lookup the target by name only after evaluation of generator
expressions.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9ba8456..0c96c91 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2012,6 +2012,24 @@ static void processIncludeDirectories(cmTarget const* tgt, for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { + std::string targetName = (*it)->TargetName; + bool checkCMP0027 = false; + if(!cmGeneratorExpression::IsValidTargetName(targetName) + && cmGeneratorExpression::Find(targetName) != std::string::npos) + { + std::string evaluatedTargetName; + cmGeneratorExpression ge; + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(targetName); + evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); + checkCMP0027 = evaluatedTargetName != targetName; + targetName = evaluatedTargetName; + } + cmTarget *dependentTarget = mf->FindTargetToUse(targetName); + + const bool fromImported = + dependentTarget && dependentTarget->IsImported(); + bool testIsOff = true; bool cacheIncludes = false; std::vector<std::string>& entryIncludes = (*it)->CachedEntries; @@ -2037,36 +2055,12 @@ static void processIncludeDirectories(cmTarget const* tgt, for(std::vector<std::string>::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { - std::string targetName = (*it)->TargetName; - std::string evaluatedTargetName; - { - cmGeneratorExpression ge; - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(targetName); - evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); - } - - cmTarget *dependentTarget = mf->FindTargetToUse(targetName); - - const bool fromImported = dependentTarget - && dependentTarget->IsImported(); - - cmTarget *evaluatedDependentTarget = - (targetName != evaluatedTargetName) - ? mf->FindTargetToUse(evaluatedTargetName) - : 0; - - targetName = evaluatedTargetName; - - const bool fromEvaluatedImported = evaluatedDependentTarget - && evaluatedDependentTarget->IsImported(); - - if ((fromImported || fromEvaluatedImported) + if (fromImported && !cmSystemTools::FileExists(li->c_str())) { cmOStringStream e; cmake::MessageType messageType = cmake::FATAL_ERROR; - if (fromEvaluatedImported) + if (checkCMP0027) { switch(tgt->GetPolicyStatusCMP0027()) { |