mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-13 12:59:55 -05:00
Handle genexes when evaluating INTERFACE_INCLUDE_DIRECTORIES errors.
This commit is contained in:
@@ -236,6 +236,11 @@ cmPolicies::cmPolicies()
|
||||
CMP0026, "CMP0026",
|
||||
"Disallow use of the LOCATION target property.",
|
||||
3,0,0,0, cmPolicies::WARN);
|
||||
|
||||
this->DefinePolicy(
|
||||
CMP0027, "CMP0027",
|
||||
"Conditionally linked imported targets with missing include directories.",
|
||||
3,0,0,0, cmPolicies::WARN);
|
||||
}
|
||||
|
||||
cmPolicies::~cmPolicies()
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
CMP0024, ///< Disallow including export() result.
|
||||
CMP0025, ///< Compiler id for Apple Clang is now AppleClang
|
||||
CMP0026, ///< Disallow use of the LOCATION target property.
|
||||
CMP0027, ///< Conditionally linked imported targets with missing include
|
||||
/// directories.
|
||||
|
||||
/** \brief Always the last entry.
|
||||
*
|
||||
|
||||
@@ -1911,19 +1911,56 @@ static void processIncludeDirectories(cmTarget *tgt,
|
||||
}
|
||||
}
|
||||
std::string usedIncludes;
|
||||
cmListFileBacktrace lfbt;
|
||||
for(std::vector<std::string>::iterator
|
||||
li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
|
||||
{
|
||||
cmTarget *dependentTarget =
|
||||
mf->FindTargetToUse((*it)->TargetName.c_str());
|
||||
std::string targetName = (*it)->TargetName;
|
||||
std::string evaluatedTargetName;
|
||||
{
|
||||
cmGeneratorExpression ge(lfbt);
|
||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(targetName);
|
||||
evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0);
|
||||
}
|
||||
|
||||
cmTarget *dependentTarget = mf->FindTargetToUse(targetName.c_str());
|
||||
|
||||
const bool fromImported = dependentTarget
|
||||
&& dependentTarget->IsImported();
|
||||
|
||||
if (fromImported && !cmSystemTools::FileExists(li->c_str()))
|
||||
cmTarget *evaluatedDependentTarget =
|
||||
(targetName != evaluatedTargetName)
|
||||
? mf->FindTargetToUse(evaluatedTargetName.c_str())
|
||||
: 0;
|
||||
|
||||
targetName = evaluatedTargetName;
|
||||
|
||||
const bool fromEvaluatedImported = evaluatedDependentTarget
|
||||
&& evaluatedDependentTarget->IsImported();
|
||||
|
||||
if ((fromImported || fromEvaluatedImported)
|
||||
&& !cmSystemTools::FileExists(li->c_str()))
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "Imported target \"" << (*it)->TargetName << "\" includes "
|
||||
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
||||
if (fromEvaluatedImported)
|
||||
{
|
||||
switch(mf->GetPolicyStatus(cmPolicies::CMP0027))
|
||||
{
|
||||
case cmPolicies::WARN:
|
||||
e << (mf->GetPolicies()
|
||||
->GetPolicyWarning(cmPolicies::CMP0027)) << "\n";
|
||||
case cmPolicies::OLD:
|
||||
messageType = cmake::AUTHOR_WARNING;
|
||||
break;
|
||||
case cmPolicies::REQUIRED_ALWAYS:
|
||||
case cmPolicies::REQUIRED_IF_USED:
|
||||
case cmPolicies::NEW:
|
||||
break;
|
||||
}
|
||||
}
|
||||
e << "Imported target \"" << targetName << "\" includes "
|
||||
"non-existent path\n \"" << *li << "\"\nin its "
|
||||
"INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
|
||||
"* The path was deleted, renamed, or moved to another "
|
||||
@@ -1932,7 +1969,7 @@ static void processIncludeDirectories(cmTarget *tgt,
|
||||
"successfully.\n"
|
||||
"* The installation package was faulty and references files it "
|
||||
"does not provide.\n";
|
||||
tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
|
||||
tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1941,9 +1978,9 @@ static void processIncludeDirectories(cmTarget *tgt,
|
||||
cmOStringStream e;
|
||||
bool noMessage = false;
|
||||
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
||||
if (!(*it)->TargetName.empty())
|
||||
if (!targetName.empty())
|
||||
{
|
||||
e << "Target \"" << (*it)->TargetName << "\" contains relative "
|
||||
e << "Target \"" << targetName << "\" contains relative "
|
||||
"path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
|
||||
" \"" << *li << "\"";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user