mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
find_* commands: ensure correct checks for VALIDATOR option
Ensure, regardless where the command is defined, that a macro is not accepted as value for VALIDATOR option.
This commit is contained in:
@@ -184,18 +184,16 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
|
||||
}
|
||||
// ensure a macro is not specified as validator
|
||||
auto const& validatorName = args[j];
|
||||
cmList macros{ this->Makefile->GetProperty("MACROS") };
|
||||
if (std::find_if(macros.begin(), macros.end(),
|
||||
[&validatorName](std::string const& item) {
|
||||
return cmSystemTools::Strucmp(validatorName.c_str(),
|
||||
item.c_str()) == 0;
|
||||
}) != macros.end()) {
|
||||
if (this->Makefile->GetState()
|
||||
->GetCommandType(validatorName)
|
||||
.value_or(cmStateEnums::CommandType::Macro) !=
|
||||
cmStateEnums::CommandType::Function) {
|
||||
this->SetError(cmStrCat(
|
||||
"command specified for VALIDATOR is not a function: ", args[j],
|
||||
'.'));
|
||||
return false;
|
||||
}
|
||||
this->ValidatorName = args[j];
|
||||
this->ValidatorName = validatorName;
|
||||
} else if (this->CheckCommonArgument(args[j])) {
|
||||
doing = DoingNone;
|
||||
} else {
|
||||
|
||||
@@ -2,3 +2,9 @@ CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_file\):
|
||||
find_file command specified for VALIDATOR is not a function: check\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_file\):
|
||||
find_file command specified for VALIDATOR is not a function: check2\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -3,3 +3,6 @@ macro(CHECK result path)
|
||||
endmacro()
|
||||
|
||||
find_file(result NAMES input.txt VALIDATOR check)
|
||||
|
||||
add_subdirectory(subdir)
|
||||
find_file(result NAMES input.txt VALIDATOR check2)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
macro(CHECK2 result path)
|
||||
endmacro()
|
||||
@@ -2,3 +2,9 @@ CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_library\):
|
||||
find_library command specified for VALIDATOR is not a function: check\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_library\):
|
||||
find_library command specified for VALIDATOR is not a function: check2\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -3,3 +3,6 @@ macro(CHECK result path)
|
||||
endmacro()
|
||||
|
||||
find_library(result NAMES input.txt VALIDATOR check)
|
||||
|
||||
add_subdirectory(subdir)
|
||||
find_library(result NAMES input.txt VALIDATOR check2)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
macro(CHECK2 result path)
|
||||
endmacro()
|
||||
@@ -2,3 +2,9 @@ CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_path\):
|
||||
find_path command specified for VALIDATOR is not a function: check\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_path\):
|
||||
find_path command specified for VALIDATOR is not a function: check2\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -3,3 +3,6 @@ macro(CHECK result path)
|
||||
endmacro()
|
||||
|
||||
find_path(result NAMES input.txt VALIDATOR check)
|
||||
|
||||
add_subdirectory(subdir)
|
||||
find_path(result NAMES input.txt VALIDATOR check2)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
macro(CHECK2 result path)
|
||||
endmacro()
|
||||
@@ -2,3 +2,9 @@ CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_program\):
|
||||
find_program command specified for VALIDATOR is not a function: check\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at VALIDATOR-specify-macro\.cmake:[0-9]+ \(find_program\):
|
||||
find_program command specified for VALIDATOR is not a function: check2\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -3,3 +3,6 @@ macro(CHECK result path)
|
||||
endmacro()
|
||||
|
||||
find_program(result NAMES input.txt VALIDATOR check)
|
||||
|
||||
add_subdirectory(subdir)
|
||||
find_program(result NAMES input.txt VALIDATOR check2)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
macro(CHECK2 result path)
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user