summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry Schreiner <hschrein@cern.ch>2018-05-02 21:51:05 (GMT)
committerBrad King <brad.king@kitware.com>2018-05-03 12:34:39 (GMT)
commit4f82199befee194aa924fd4dcdb2f4aad1f7dab6 (patch)
tree9af74a279353efc6ff4feadaebd6f4d04c7d1006
parent5e455ac120fd596a0ad1a4216c5734bb52ac1b75 (diff)
downloadCMake-4f82199befee194aa924fd4dcdb2f4aad1f7dab6.zip
CMake-4f82199befee194aa924fd4dcdb2f4aad1f7dab6.tar.gz
CMake-4f82199befee194aa924fd4dcdb2f4aad1f7dab6.tar.bz2
Genex: Allow COMPILE_LANGUAGE to name a language that is not loaded
Evaluate to false on `$<COMPILE_LANGUAGE:Lang>` if language `Lang` is not loaded. This is helpful in exported targets consumed in other projects that may not enable all the same languages. Fixes: #17952
-rw-r--r--Source/cmGeneratorExpressionNode.cxx9
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake2
4 files changed, 1 insertions, 19 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 399e894..7b35bce 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1013,16 +1013,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
return std::string();
}
- std::vector<std::string> enabledLanguages;
cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
- gg->GetEnabledLanguages(enabledLanguages);
- if (!parameters.empty() &&
- std::find(enabledLanguages.begin(), enabledLanguages.end(),
- parameters.front()) == enabledLanguages.end()) {
- reportError(context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> Unknown language.");
- return std::string();
- }
std::string genName = gg->GetName();
if (genName.find("Makefiles") == std::string::npos &&
genName.find("Ninja") == std::string::npos &&
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt
deleted file mode 100644
index 444da45..0000000
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at COMPILE_LANGUAGE-unknown-lang.cmake:4 \(target_compile_options\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> Unknown language.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
index cec12a3..00dd290 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
@@ -1,4 +1,4 @@
enable_language(C)
add_executable(empty empty.c)
-target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wall>)
+target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:$<TARGET_EXISTS:too,many,parameters>>)