summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-06 12:51:05 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-06 12:51:05 (GMT)
commit8317ea01aa3cf9319ef907e127fa6dbf9666cc53 (patch)
tree68c593e28b22ac0496001a35087ad3e226cf6b83
parent9109ba434782a3514f1bc6a5fd3c063d231008f2 (diff)
parentf6fd0abc5bbfa7d677cd090ba8e2894d96afdde8 (diff)
downloadCMake-8317ea01aa3cf9319ef907e127fa6dbf9666cc53.zip
CMake-8317ea01aa3cf9319ef907e127fa6dbf9666cc53.tar.gz
CMake-8317ea01aa3cf9319ef907e127fa6dbf9666cc53.tar.bz2
Merge topic 'genex-LINK_ONLY-not-linking'
f6fd0abc Genex: Diagnose invalid LINK_ONLY usage instead of crashing
-rw-r--r--Source/cmGeneratorExpressionNode.cxx11
-rw-r--r--Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking.cmake1
-rw-r--r--Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake1
5 files changed, 19 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 44e9ce1..c19a741 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -672,15 +672,20 @@ static const struct LinkOnlyNode : public cmGeneratorExpressionNode
LinkOnlyNode() {}
std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const
CM_OVERRIDE
{
+ if (!dagChecker) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_ONLY:...> may only be used for linking");
+ return std::string();
+ }
if (!dagChecker->GetTransitivePropertiesOnly()) {
return parameters.front();
}
- return "";
+ return std::string();
}
} linkOnlyNode;
diff --git a/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-result.txt b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-stderr.txt b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-stderr.txt
new file mode 100644
index 0000000..cded130
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at LINK_ONLY-not-linking.cmake:1 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<LINK_ONLY:something>
+
+ \$<LINK_ONLY:...> may only be used for linking
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking.cmake b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking.cmake
new file mode 100644
index 0000000..16db0a2
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/LINK_ONLY-not-linking.cmake
@@ -0,0 +1 @@
+add_custom_target(Custom ALL COMMAND ${CMAKE_COMMAND} -E echo $<LINK_ONLY:something>)
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index 625bab2..f5584d5 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -29,6 +29,7 @@ run_cmake(COMPILE_LANGUAGE-unknown-lang)
run_cmake(TARGET_FILE-recursion)
run_cmake(OUTPUT_NAME-recursion)
run_cmake(TARGET_PROPERTY-LOCATION)
+run_cmake(LINK_ONLY-not-linking)
run_cmake(ImportedTarget-TARGET_PDB_FILE)
if(LINKER_SUPPORTS_PDB)