From b9f98dd8cd53ace51c731b2439b35fbfd98883ec Mon Sep 17 00:00:00 2001 From: Aniket Teredesai <50461557+icy-comet@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:42:36 +0530 Subject: [build]: add uninstall cmake target (#3511) --- cmake/Uninstall.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cmake/Uninstall.cmake (limited to 'cmake') diff --git a/cmake/Uninstall.cmake b/cmake/Uninstall.cmake new file mode 100644 index 00000000..c2d34d47 --- /dev/null +++ b/cmake/Uninstall.cmake @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif() + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +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 + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif() + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() -- cgit v1.2.3