From 3b47f22293abe4ebfd1b829674ff5edb265922d9 Mon Sep 17 00:00:00 2001 From: jsnowy Date: Sun, 15 Sep 2024 21:48:39 +0800 Subject: [PATCH] Replace deprecated cmd to Fix Uninstall --- cmake_uninstall.cmake.in | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in index 0c9f6a437..23308f863 100644 --- a/cmake_uninstall.cmake.in +++ b/cmake_uninstall.cmake.in @@ -7,15 +7,22 @@ string(REGEX REPLACE "\n" ";" files "${files}") foreach (file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program("@CMAKE_COMMAND@" - ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval + execute_process( + # remove deprecated: use rm instead, + # because it does not check the file path, even return an error. + COMMAND "@CMAKE_COMMAND@" -E rm "$ENV{DESTDIR}${file}" + RESULT_VARIABLE rm_retval + ERROR_VARIABLE rm_err ) if (NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}\n${rm_err}") + # Detect whether the file has been removed. + elseif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(FATAL_ERROR "File has not been removed.\n${rm_err}") + else() + message(STATUS "File has been removed.") endif () - else (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + else () message(STATUS "File $ENV{DESTDIR}${file} does not exist.") endif () -endforeach () +endforeach () \ No newline at end of file