xref: /aosp_15_r20/external/libultrahdr/cmake/cmake_uninstall.cmake.in (revision 89a0ef05262152531a00a15832a2d3b1e3990773)
1# Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
2
3if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
4  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
5endif()
6
7file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
8string(REGEX REPLACE "\n" ";" files "${files}")
9foreach(file ${files})
10  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
11  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
12    execute_process(COMMAND ${CMAKE_COMMAND} -E remove "$ENV{DESTDIR}${file}"
13                    OUTPUT_VARIABLE rm_out
14                    RESULT_VARIABLE rm_retval)
15    if(NOT "${rm_retval}" STREQUAL 0)
16      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
17    endif()
18  else()
19    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
20  endif()
21endforeach()