Genex: Make LINK_LANGUAGE report an error when evaluating link libraries.

This commit is contained in:
Stephen Kelly 2013-06-14 15:59:23 +02:00
parent 0e1cb07e84
commit b1c19ce383
6 changed files with 27 additions and 1 deletions

View File

@ -415,8 +415,15 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode
std::string Evaluate(const std::vector<std::string> &parameters, std::string Evaluate(const std::vector<std::string> &parameters,
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(),

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,6 @@
CMake Error:
Error evaluating generator expression:
\$<LINK_LANGUAGE>
\$<LINK_LANGUAGE> expression can not be used while evaluating link libraries

View File

@ -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>)

View File

@ -1,3 +1,4 @@
include(RunCMake) include(RunCMake)
run_cmake(NoLangSHARED) run_cmake(NoLangSHARED)
run_cmake(LINK_LANGUAGE-genex)

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
int empty(void)
{
return 0;
}