diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-06-14 13:59:23 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-06-24 14:21:53 (GMT) |
commit | b1c19ce3837036bde3b639f8285fa228b8e6f278 (patch) | |
tree | 3c6fa9415dcfd4e6232a926072f7ca4f4db752c6 | |
parent | 0e1cb07e841c5ca9207bc4e32ff0672476226cc0 (diff) | |
download | CMake-b1c19ce3837036bde3b639f8285fa228b8e6f278.zip CMake-b1c19ce3837036bde3b639f8285fa228b8e6f278.tar.gz CMake-b1c19ce3837036bde3b639f8285fa228b8e6f278.tar.bz2 |
Genex: Make LINK_LANGUAGE report an error when evaluating link libraries.
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 9 | ||||
-rw-r--r-- | Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Languages/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Languages/empty.cpp | 7 |
6 files changed, 27 insertions, 1 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 3e18bba..cd0d26b 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -415,8 +415,15 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *context, 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) { reportError(context, content->GetOriginalExpression(), diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt new file mode 100644 index 0000000..8e0591d --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt @@ -0,0 +1,6 @@ +CMake Error: + Error evaluating generator expression: + + \$<LINK_LANGUAGE> + + \$<LINK_LANGUAGE> expression can not be used while evaluating link libraries diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake new file mode 100644 index 0000000..e0f8c57 --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake @@ -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>) diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake index a99548f..59ef5dc 100644 --- a/Tests/RunCMake/Languages/RunCMakeTest.cmake +++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(NoLangSHARED) +run_cmake(LINK_LANGUAGE-genex) diff --git a/Tests/RunCMake/Languages/empty.cpp b/Tests/RunCMake/Languages/empty.cpp new file mode 100644 index 0000000..7279c5e --- /dev/null +++ b/Tests/RunCMake/Languages/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty(void) +{ + return 0; +} |