← Back to team overview

cuneiform team mailing list archive

Make uninstall support before release

 

Hello!

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:

http://openocr.org/forum/viewtopic.php?f=3&t=2914

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

http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F

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 

/usr/share/cuneiform 

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 :-) ?

Best,
 
-- 
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 @@
 
 add_subdirectory(datafiles)
 add_subdirectory(cuneiform_src)
+
+# ZYV: make uninstall target support
+
+CONFIGURE_FILE(
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+  IMMEDIATE @ONLY)
+
+ADD_CUSTOM_TARGET(uninstall
+  "${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\"")
+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(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(EXISTS "$ENV{DESTDIR}${file}")
+    MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+  ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)


Follow ups