Merge topic 'dag-LINKER_LANGUAGE'
ff015ee
Genex: Report error if a target file is needed to evaluate link libraries.b58aff9
Genex: Extend EvaluatingLinkLibraries to also check the top target name.b1c19ce
Genex: Make LINK_LANGUAGE report an error when evaluating link libraries.0e1cb07
Add missing return after error report.
This commit is contained in:
commit
bef7c0251e
|
@ -139,7 +139,7 @@ cmGeneratorExpressionDAGChecker::checkGraph() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries()
|
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt)
|
||||||
{
|
{
|
||||||
const cmGeneratorExpressionDAGChecker *top = this;
|
const cmGeneratorExpressionDAGChecker *top = this;
|
||||||
const cmGeneratorExpressionDAGChecker *parent = this->Parent;
|
const cmGeneratorExpressionDAGChecker *parent = this->Parent;
|
||||||
|
@ -150,6 +150,12 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries()
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *prop = top->Property.c_str();
|
const char *prop = top->Property.c_str();
|
||||||
|
|
||||||
|
if (tgt)
|
||||||
|
{
|
||||||
|
return top->Target == tgt && strcmp(prop, "LINK_LIBRARIES") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return (strcmp(prop, "LINK_LIBRARIES") == 0
|
return (strcmp(prop, "LINK_LIBRARIES") == 0
|
||||||
|| strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0
|
|| strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0
|
||||||
|| strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|
|| strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct cmGeneratorExpressionDAGChecker
|
||||||
void reportError(cmGeneratorExpressionContext *context,
|
void reportError(cmGeneratorExpressionContext *context,
|
||||||
const std::string &expr);
|
const std::string &expr);
|
||||||
|
|
||||||
bool EvaluatingLinkLibraries();
|
bool EvaluatingLinkLibraries(const char *tgt = 0);
|
||||||
|
|
||||||
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
||||||
bool METHOD () const;
|
bool METHOD () const;
|
||||||
|
|
|
@ -469,8 +469,15 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode
|
||||||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||||
cmGeneratorExpressionContext *context,
|
cmGeneratorExpressionContext *context,
|
||||||
const GeneratorExpressionContent *content,
|
const GeneratorExpressionContent *content,
|
||||||
cmGeneratorExpressionDAGChecker *) const
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
||||||
{
|
{
|
||||||
|
if (dagChecker && dagChecker->EvaluatingLinkLibraries())
|
||||||
|
{
|
||||||
|
reportError(context, content->GetOriginalExpression(),
|
||||||
|
"$<LINK_LANGUAGE> expression can not be used while evaluating "
|
||||||
|
"link libraries");
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
if (parameters.size() != 0 && parameters.size() != 1)
|
if (parameters.size() != 0 && parameters.size() != 1)
|
||||||
{
|
{
|
||||||
reportError(context, content->GetOriginalExpression(),
|
reportError(context, content->GetOriginalExpression(),
|
||||||
|
@ -483,6 +490,7 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode
|
||||||
reportError(context, content->GetOriginalExpression(),
|
reportError(context, content->GetOriginalExpression(),
|
||||||
"$<LINK_LANGUAGE> may only be used with targets. It may not "
|
"$<LINK_LANGUAGE> may only be used with targets. It may not "
|
||||||
"be used with add_custom_command.");
|
"be used with add_custom_command.");
|
||||||
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *lang = target->GetLinkerLanguage(context->Config);
|
const char *lang = target->GetLinkerLanguage(context->Config);
|
||||||
|
@ -1146,7 +1154,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
||||||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||||
cmGeneratorExpressionContext *context,
|
cmGeneratorExpressionContext *context,
|
||||||
const GeneratorExpressionContent *content,
|
const GeneratorExpressionContent *content,
|
||||||
cmGeneratorExpressionDAGChecker *) const
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
||||||
{
|
{
|
||||||
// Lookup the referenced target.
|
// Lookup the referenced target.
|
||||||
std::string name = *parameters.begin();
|
std::string name = *parameters.begin();
|
||||||
|
@ -1171,6 +1179,13 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
||||||
"Target \"" + name + "\" is not an executable or library.");
|
"Target \"" + name + "\" is not an executable or library.");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
|
||||||
|
{
|
||||||
|
::reportError(context, content->GetOriginalExpression(),
|
||||||
|
"Expressions which require the linker language may not "
|
||||||
|
"be used while evaluating link libraries");
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
context->DependTargets.insert(target);
|
context->DependTargets.insert(target);
|
||||||
context->AllTargets.insert(target);
|
context->AllTargets.insert(target);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,6 @@
|
||||||
|
CMake Error:
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<LINK_LANGUAGE>
|
||||||
|
|
||||||
|
\$<LINK_LANGUAGE> expression can not be used while evaluating link libraries
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
add_library(foo SHARED empty.cpp)
|
||||||
|
add_library(bar SHARED empty.cpp)
|
||||||
|
target_link_libraries(foo $<$<STREQUAL:$<LINK_LANGUAGE>,anything>:bar>)
|
|
@ -1,3 +1,6 @@
|
||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
|
||||||
run_cmake(NoLangSHARED)
|
run_cmake(NoLangSHARED)
|
||||||
|
run_cmake(LINK_LANGUAGE-genex)
|
||||||
|
run_cmake(link-libraries-TARGET_FILE-genex)
|
||||||
|
run_cmake(link-libraries-TARGET_FILE-genex-ok)
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
|
int empty(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
enable_language(CXX)
|
||||||
|
|
||||||
|
add_library(foo SHARED empty.cpp)
|
||||||
|
add_library(bar SHARED empty.cpp)
|
||||||
|
target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:bar>,anything>:bar>)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,7 @@
|
||||||
|
CMake Error:
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<TARGET_FILE:foo>
|
||||||
|
|
||||||
|
Expressions which require the linker language may not be used while
|
||||||
|
evaluating link libraries
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
add_library(foo SHARED empty.cpp)
|
||||||
|
add_library(bar SHARED empty.cpp)
|
||||||
|
target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:foo>,anything>:bar>)
|
Loading…
Reference in New Issue