From 4f82199befee194aa924fd4dcdb2f4aad1f7dab6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 2 May 2018 17:51:05 -0400 Subject: Genex: Allow COMPILE_LANGUAGE to name a language that is not loaded Evaluate to false on `$` 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 --- Source/cmGeneratorExpressionNode.cxx | 9 --------- .../GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt | 1 - .../GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt | 8 -------- .../GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake | 2 +- 4 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt delete mode 100644 Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt 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 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(), - "$ 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: - - \$ - - \$ 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 $<$:-Wall>) +target_compile_options(empty PRIVATE $<$:$>) -- cgit v0.12