aboutsummaryrefslogtreecommitdiff
path: root/modules/ecm_uninstall.cmake.in
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@kde.org>2015-02-01 11:20:43 +0000
committerAlex Merry <alex.merry@kde.org>2015-02-04 18:29:47 +0000
commit807ace309a489d21163b5c671d9e449c06e14e20 (patch)
treecfb1fd0e14ec49ad42d7ae2b4f32b1a4788b4e81 /modules/ecm_uninstall.cmake.in
parentfea3b11ca01677e60d552ac29091b28946c99f08 (diff)
downloadextra-cmake-modules-807ace309a489d21163b5c671d9e449c06e14e20.tar.gz
extra-cmake-modules-807ace309a489d21163b5c671d9e449c06e14e20.tar.bz2
Add a module to provide an uninstall target.
This is basically just the code available on the CMake FAQ item about `make uninstall`, but packaged up in a convenient module. REVIEW: 122359
Diffstat (limited to 'modules/ecm_uninstall.cmake.in')
-rw-r--r--modules/ecm_uninstall.cmake.in21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/ecm_uninstall.cmake.in b/modules/ecm_uninstall.cmake.in
new file mode 100644
index 00000000..d0cf1241
--- /dev/null
+++ b/modules/ecm_uninstall.cmake.in
@@ -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(NOT "${rm_retval}" STREQUAL 0)
+ else()
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif()
+endforeach()