From 36780583dd78865100114b02627a3418b2d56deb Mon Sep 17 00:00:00 2001 From: jiseongg Date: Sat, 16 Jan 2021 15:14:06 +0900 Subject: Add cmake custom target `uninstall` `make uninstall` is enabled. Without this, uninstalling was done manually with `rm` command. --- cmake/cmake_uninstall.cmake.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cmake/cmake_uninstall.cmake.in (limited to 'cmake') diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 00000000..bfc45583 --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,24 @@ +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}) + set(file_path "$ENV{DESTDIR}${file}") + message(STATUS "Uninstalling ${file_path}") + if(IS_SYMLINK "${file_path}" OR EXISTS "${file_path}") + # We could use ``file(REMOVE ...)`` here but then we wouldn't + # know if the removal failed. + execute_process(COMMAND + "@CMAKE_COMMAND@" "-E" "remove" "${file_path}" + RESULT_VARIABLE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing \"${file_path}\"") + endif() + else() + message(STATUS "File \"${file_path}\" does not exist.") + endif() +endforeach() -- cgit 1.4.1