From f3ad225294a37440fb61f7316e0b11e9b97eb1de Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 27 Oct 2014 10:24:51 -0400 Subject: [PATCH] umtrx: uninstall target for cmake build --- host/CMakeLists.txt | 11 +++++++++++ host/cmake_uninstall.cmake.in | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 host/cmake_uninstall.cmake.in diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 0bc12843..0d1ea229 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -151,3 +151,14 @@ install( ) add_subdirectory(utils) + +######################################################################## +# uninstall target +######################################################################## +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) diff --git a/host/cmake_uninstall.cmake.in b/host/cmake_uninstall.cmake.in new file mode 100644 index 00000000..2037e365 --- /dev/null +++ b/host/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_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(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file)