diff options
author | jiseongg <jiseongg301@gmail.com> | 2021-01-16 15:14:06 +0900 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2021-03-05 22:03:13 +0000 |
commit | 36780583dd78865100114b02627a3418b2d56deb (patch) | |
tree | 5d8ed323aba94e01211fe7e1439a4c1ca118eed0 | |
parent | b1ef0c8a7bd433b81c057ecad656608a82a3b7dc (diff) | |
download | klee-36780583dd78865100114b02627a3418b2d56deb.tar.gz |
Add cmake custom target `uninstall`
`make uninstall` is enabled. Without this, uninstalling was done manually with `rm` command.
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | cmake/cmake_uninstall.cmake.in | 24 |
2 files changed, 40 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e5d4aa1..1d00d7f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -814,3 +814,19 @@ endif() # Miscellaneous install ################################################################################ install(FILES include/klee/klee.h DESTINATION include/klee) + +################################################################################ +# Uninstall rule +################################################################################ +configure_file( + "${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY +) + +add_custom_target(uninstall + COMMAND + "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" + COMMENT "Uninstalling..." + VERBATIM +) 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() |