From 42e417ad1223a776399b427de2216b838a0bc1f6 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 17 Jan 2023 12:14:09 -0500 Subject: GeneratorExpression Tests: Remove duplicate test entry --- Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 8d8c8dc..2d545d9 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -12,7 +12,6 @@ run_cmake(BadTargetTypeInterface) run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) run_cmake(BadSHELL_PATH) -run_cmake(BadCONFIG) run_cmake(CMP0044-WARN) run_cmake(NonValidTarget-C_COMPILER_ID) run_cmake(NonValidTarget-CXX_COMPILER_ID) -- cgit v0.12 From 910ada1a88f4196cd441d6c6cde9c30629785d6e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 17 Jan 2023 13:04:13 -0500 Subject: Genex: $ syntax of all entries checked Fixes #24327 --- Source/cmGeneratorExpressionNode.cxx | 24 +++++++++++++++++++--- .../GeneratorExpression/BadCONFIG-stderr.txt | 9 ++++++++ Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index e33ebd7..6595323 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1352,12 +1352,30 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode } static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$"); if (!configValidator.find(parameters.front())) { - reportError(context, content->GetOriginalExpression(), - "Expression syntax not recognized."); - return std::string(); } + context->HadContextSensitiveCondition = true; + bool firstParam = true; for (auto const& param : parameters) { + if (!configValidator.find(param)) { + if (firstParam) { + reportError(context, content->GetOriginalExpression(), + "Expression syntax not recognized."); + return std::string(); + } + // for backwards compat invalid config names are only errors as + // the first parameter + std::ostringstream e; + /* clang-format off */ + e << "Warning evaluating generator expression:\n" + << " " << content->GetOriginalExpression() << "\n" + << "The config name of \"" << param << "\" is invalid"; + /* clang-format on */ + context->LG->GetCMakeInstance()->IssueMessage( + MessageType::WARNING, e.str(), context->Backtrace); + } + + firstParam = false; if (context->Config.empty()) { if (param.empty()) { return "1"; diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 130de2b..b61ccd2 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -25,4 +25,13 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + +CMake Warning at BadCONFIG.cmake:1 \(add_custom_target\): + Warning evaluating generator expression: + + \$ + + The config name of "Foo-Second" is invalid +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake index 1735ab7..4d7a357 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake @@ -2,4 +2,5 @@ add_custom_target(check ALL COMMAND check $ $ $<$:foo> + $<$:foo> VERBATIM) -- cgit v0.12