mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-08 08:40:48 +00:00
Merge topic 'if-invalid'
240481490c if: Diagnose invalid argument in parentheses
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12114
This commit is contained in:
@@ -409,6 +409,9 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
|
||||
// now recursively invoke IsTrue to handle the values inside the
|
||||
// parenthetical expression
|
||||
auto const value = this->IsTrue(subExpr, errorString, status);
|
||||
if (!errorString.empty()) {
|
||||
return false;
|
||||
}
|
||||
*arg = cmExpandedCommandArgument(bool2string(value), true);
|
||||
argOpen = std::next(arg);
|
||||
// remove the now evaluated parenthetical expression
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,8 @@
|
||||
^CMake Error at InvalidArgumentInParenthesis\.cmake:1 \(if\):
|
||||
if given arguments:
|
||||
|
||||
"\(" "A" "B" "\)" "OR" "\(" "" "\)"
|
||||
|
||||
Unknown arguments specified
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)$
|
||||
5
Tests/RunCMake/if/InvalidArgumentInParenthesis.cmake
Normal file
5
Tests/RunCMake/if/InvalidArgumentInParenthesis.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
if((A B) OR ("$ENV{NOT_AN_ENV_VARIABLE}"))
|
||||
message(STATUS "Invalid evaluated to TRUE")
|
||||
else()
|
||||
message(STATUS "Invalid evaluated to FALSE")
|
||||
endif()
|
||||
@@ -1,6 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(InvalidArgument1)
|
||||
run_cmake(InvalidArgumentInParenthesis)
|
||||
run_cmake(exists)
|
||||
if(NOT MSYS)
|
||||
# permissions and symbolic links are broken on MSYS
|
||||
|
||||
1
Tests/RunCMake/while/InvalidArgument-result.txt
Normal file
1
Tests/RunCMake/while/InvalidArgument-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
8
Tests/RunCMake/while/InvalidArgument-stderr.txt
Normal file
8
Tests/RunCMake/while/InvalidArgument-stderr.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
^CMake Error at InvalidArgument\.cmake:2 \(while\):
|
||||
while\(\) given incorrect arguments:
|
||||
|
||||
"\(" "A" "B" "\)" "OR" "\(" "" "\)"
|
||||
|
||||
Unknown arguments specified
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)$
|
||||
6
Tests/RunCMake/while/InvalidArgument.cmake
Normal file
6
Tests/RunCMake/while/InvalidArgument.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
cmake_policy(SET CMP0130 NEW)
|
||||
while((A B) OR ("$ENV{NOT_AN_ENV_VARIABLE}"))
|
||||
message(STATUS "Invalid evaluated to TRUE")
|
||||
return()
|
||||
endwhile()
|
||||
message(STATUS "Invalid evaluated to FALSE")
|
||||
@@ -1,6 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(MissingArgument)
|
||||
run_cmake(InvalidArgument)
|
||||
run_cmake(EndMissing)
|
||||
run_cmake(EndMismatch)
|
||||
run_cmake(EndAlone)
|
||||
|
||||
Reference in New Issue
Block a user