about summary refs log tree commit diff homepage
path: root/cmake/cmake_uninstall.cmake.in
blob: bfc4558398c581ec907c03cacac945151e266de5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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})
  set(file_path "$ENV{DESTDIR}${file}")
  message(STATUS "Uninstalling ${file_path}")
  if(IS_SYMLINK "${file_path}" OR EXISTS "${file_path}")
    # We could use ``file(REMOVE ...)`` here but then we wouldn't
    # know if the removal failed.
    execute_process(COMMAND
      "@CMAKE_COMMAND@" "-E" "remove" "${file_path}"
      RESULT_VARIABLE rm_retval
    )
    if(NOT "${rm_retval}" STREQUAL 0)
      message(FATAL_ERROR "Problem when removing \"${file_path}\"")
    endif()
  else()
    message(STATUS "File \"${file_path}\" does not exist.")
  endif()
endforeach()