cmake: add error message when '-E touch' fails

Issue: #16526
This commit is contained in:
Isaiah Norton
2018-11-27 13:23:29 -05:00
parent f49efe283e
commit 100366a267
4 changed files with 8 additions and 0 deletions

View File

@@ -691,6 +691,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (args[1] == "touch" && args.size() > 2) {
for (std::string::size_type cc = 2; cc < args.size(); cc++) {
if (!cmSystemTools::Touch(args[cc], true)) {
std::cerr << "cmake -E touch: failed to update \"";
std::cerr << args[cc] << "\".\n";
return 1;
}
}
@@ -701,6 +703,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (args[1] == "touch_nocreate" && args.size() > 2) {
for (std::string::size_type cc = 2; cc < args.size(); cc++) {
if (!cmSystemTools::Touch(args[cc], false)) {
std::cerr << "cmake -E touch_nocreate: failed to update \"";
std::cerr << args[cc] << "\".\n";
return 1;
}
}

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
^cmake -E touch: failed to update ".+/touch-nonexistent-dir/foo"\.$

View File

@@ -22,7 +22,9 @@ run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append)
run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename)
run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg)
run_cmake_command(E_server-pipe ${CMAKE_COMMAND} -E server --pipe=)
run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate)
run_cmake_command(E_touch-nonexistent-dir ${CMAKE_COMMAND} -E touch "${RunCMake_BINARY_DIR}/touch-nonexistent-dir/foo")
run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world")
run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time)