cmake: Support make uninstall.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 7 Feb 2008 18:41:31 +0000 (18:41 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 7 Feb 2008 18:41:31 +0000 (18:41 +0000)
extras/buildsystem/cmake/CMakeLists/root_CMakeLists.txt
extras/buildsystem/cmake/cmake_uninstall.cmake.in [new file with mode: 0644]

index 84d0a3f..7ab145e 100644 (file)
@@ -28,6 +28,15 @@ add_subdirectory(src)
 add_subdirectory(modules)
 add_subdirectory(po)
 
+# Enable uninstall
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/extras/buildsystem/cmake/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")
+
 # Enable CPack: Automatic package creation
 
 set(README "${CMAKE_CURRENT_SOURCE_DIR}/README")
diff --git a/extras/buildsystem/cmake/cmake_uninstall.cmake.in b/extras/buildsystem/cmake/cmake_uninstall.cmake.in
new file mode 100644 (file)
index 0000000..df95fb9
--- /dev/null
@@ -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(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)