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}")
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(
"@CMAKE_COMMAND@"
ARGS
"-E remove \"$ENV{DESTDIR}${file}\""
"-E remove \"${filepath}\""
OUTPUT_VARIABLE
rm_out
RETURN_VALUE
@@ -39,9 +40,9 @@ foreach(file ${files})
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
message(FATAL_ERROR "Problem when removing ${filepath}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
else(IS_SYMLINK "${filepath}" OR EXISTS "${filepath}")
message(STATUS "File ${filepath} does not exist.")
endif()
endforeach()