← Back to team overview

cuneiform team mailing list archive

Make uninstall support before release



Yesterday on the forums, a user complained that we do not provide make
uninstall target, so that when he builds stuff from source (and the
official packages for Ubuntu are still unavailable) he can't uninstall
it cleanly afterward:


I have looked up on the internets for the solution to this problem and
came up with this:


I patched the current trunk and it seems to work very nicely, the only
shortcoming I can think of is that it does not delete the 


folder itself, only the files that it contains. But after all, I don't
think it's a big deal.

I attach the patch to this message and I would like to hear from you
what's your opinion on this problem & the solution that I have found? Do
you Jussi feel like committing this to trunk :-) ?

Sincerely yours,
Yury V. Zaytsev
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2009-02-09 12:18:26 +0000
+++ CMakeLists.txt	2009-05-08 09:05:08 +0000
@@ -27,3 +27,13 @@
+# ZYV: make uninstall target support
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

=== added file 'cmake_uninstall.cmake.in'
--- cmake_uninstall.cmake.in	1970-01-01 00:00:00 +0000
+++ cmake_uninstall.cmake.in	2009-05-08 08:57:07 +0000
@@ -0,0 +1,23 @@
+# ZYV: make uninstall target support
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+  MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@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(EXISTS "$ENV{DESTDIR}${file}")
+      "@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)
+    MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")

Follow ups