mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
separate_arguments: Fix crash on *_COMMAND with no arguments
Fixes: #21320
This commit is contained in:

committed by
Brad King

parent
b1d9a25f35
commit
747f80fe82
@@ -80,6 +80,11 @@ bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unparsedArguments.empty()) {
|
||||||
|
status.GetMakefile().AddDefinition(var, {});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string& command = unparsedArguments.front();
|
std::string& command = unparsedArguments.front();
|
||||||
|
|
||||||
if (command.empty()) {
|
if (command.empty()) {
|
||||||
|
@@ -17,3 +17,8 @@ if(NOT "${native_out}" STREQUAL "${native_exp}")
|
|||||||
message(FATAL_ERROR "separate_arguments native-style failed. "
|
message(FATAL_ERROR "separate_arguments native-style failed. "
|
||||||
"Expected\n [${native_exp}]\nbut got\n [${native_out}]\n")
|
"Expected\n [${native_exp}]\nbut got\n [${native_out}]\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
separate_arguments(empty_out NATIVE_COMMAND)
|
||||||
|
if(NOT empty_out STREQUAL "")
|
||||||
|
message(FATAL_ERROR "separate_arguments native-style failed on no arguments")
|
||||||
|
endif()
|
||||||
|
@@ -6,3 +6,8 @@ if(NOT "${unix_out}" STREQUAL "${unix_exp}")
|
|||||||
message(FATAL_ERROR "separate_arguments unix-style failed. "
|
message(FATAL_ERROR "separate_arguments unix-style failed. "
|
||||||
"Expected\n [${unix_exp}]\nbut got\n [${unix_out}]\n")
|
"Expected\n [${unix_exp}]\nbut got\n [${unix_out}]\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
separate_arguments(empty_out UNIX_COMMAND)
|
||||||
|
if(NOT empty_out STREQUAL "")
|
||||||
|
message(FATAL_ERROR "separate_arguments unix-style failed on no arguments")
|
||||||
|
endif()
|
||||||
|
@@ -6,3 +6,8 @@ if(NOT "${windows_out}" STREQUAL "${windows_exp}")
|
|||||||
message(FATAL_ERROR "separate_arguments windows-style failed. "
|
message(FATAL_ERROR "separate_arguments windows-style failed. "
|
||||||
"Expected\n [${windows_exp}]\nbut got\n [${windows_out}]\n")
|
"Expected\n [${windows_exp}]\nbut got\n [${windows_out}]\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
separate_arguments(empty_out WINDOWS_COMMAND)
|
||||||
|
if(NOT empty_out STREQUAL "")
|
||||||
|
message(FATAL_ERROR "separate_arguments windows-style failed on no arguments")
|
||||||
|
endif()
|
||||||
|
Reference in New Issue
Block a user