From b7140022dfe7dfd1f52145e190ad0ff0f6cc83bd Mon Sep 17 00:00:00 2001 From: DRC Date: Sat, 25 Jun 2011 07:33:57 +0000 Subject: Add uninstall target git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4554 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- CMakeLists.txt | 6 ++++++ cmake/cmake_uninstall.cmake.in | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 cmake/cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 675c3ddd..159de720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,3 +324,9 @@ if(BUILD_NEW_VNCVIEWER) endif() include(cmake/BuildPackages.cmake) + +# uninstall +configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "cmake_uninstall.cmake" IMMEDIATE @ONLY) + +add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 00000000..a2494592 --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,24 @@ +# This code is from the CMake FAQ + +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}") +list(REVERSE files) +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) -- cgit v1.2.3