cmake_uninstall - simplify by using common variable

This commit is contained in:
Andrej730
2026-01-26 15:52:03 +05:00
parent dbb4e91d55
commit c4c1e2ebf9
+7 -6
View File
@@ -25,13 +25,14 @@ file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}") string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files}) foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}") set(filepath "$ENV{DESTDIR}${file}")
message(STATUS "Uninstalling ${filepath}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") if(IS_SYMLINK "${filepath}" OR EXISTS "${filepath}")
exec_program( exec_program(
"@CMAKE_COMMAND@" "@CMAKE_COMMAND@"
ARGS ARGS
"-E remove \"$ENV{DESTDIR}${file}\"" "-E remove \"${filepath}\""
OUTPUT_VARIABLE OUTPUT_VARIABLE
rm_out rm_out
RETURN_VALUE RETURN_VALUE
@@ -39,9 +40,9 @@ foreach(file ${files})
) )
if(NOT "${rm_retval}" STREQUAL 0) if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") message(FATAL_ERROR "Problem when removing ${filepath}")
endif() endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") else(IS_SYMLINK "${filepath}" OR EXISTS "${filepath}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.") message(STATUS "File ${filepath} does not exist.")
endif() endif()
endforeach() endforeach()