get_filename_component: make errors fatal

Make all errors in `get_filename_component` fatal.

Fixes: #20015
This commit is contained in:
Asit Dhal
2020-06-18 08:26:32 +02:00
committed by Brad King
parent 0a7a4665be
commit 470b3a76b3
7 changed files with 13 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
{
if (args.size() < 3) {
status.SetError("called with incorrect number of arguments");
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -114,6 +115,7 @@ bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
} else {
std::string err = "unknown component " + args[2];
status.SetError(err);
cmSystemTools::SetFatalErrorOccured();
return false;
}

View File

@@ -0,0 +1,4 @@
^CMake Error at IncorrectArguments.cmake:1 \(get_filename_component\):
get_filename_component called with incorrect number of arguments
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1,2 @@
get_filename_component(var)
message("The error is fatal, so this should not print")

View File

@@ -1,4 +1,5 @@
include(RunCMake)
run_cmake(IncorrectArguments)
run_cmake(KnownComponents)
run_cmake(UnknownComponent)

View File

@@ -1,4 +1,4 @@
CMake Error at UnknownComponent.cmake:1 \(get_filename_component\):
^CMake Error at UnknownComponent.cmake:1 \(get_filename_component\):
get_filename_component unknown component BOGUS
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
CMakeLists.txt:[0-9]+ \(include\)$

View File

@@ -1 +1,2 @@
get_filename_component(var "/path/to/filename.ext.in" BOGUS)
message("The error is fatal, so this should not print")