xref: /netbsd-src/external/bsd/libevent/dist/cmake/Uninstall.cmake.in (revision 657871a79c9a2060a6255a242fa1a1ef76b56ec6)
1*657871a7Schristos# https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
2*657871a7Schristos
3*657871a7Schristosif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
4*657871a7Schristos  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
5*657871a7Schristosendif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
6*657871a7Schristos
7*657871a7Schristosfile(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
8*657871a7Schristosstring(REGEX REPLACE "\n" ";" files "${files}")
9*657871a7Schristosforeach(file ${files})
10*657871a7Schristos  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
11*657871a7Schristos  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
12*657871a7Schristos    exec_program(
13*657871a7Schristos      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
14*657871a7Schristos      OUTPUT_VARIABLE rm_out
15*657871a7Schristos      RETURN_VALUE rm_retval
16*657871a7Schristos      )
17*657871a7Schristos    if(NOT "${rm_retval}" STREQUAL 0)
18*657871a7Schristos      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
19*657871a7Schristos    endif(NOT "${rm_retval}" STREQUAL 0)
20*657871a7Schristos  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
21*657871a7Schristos    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
22*657871a7Schristos  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
23*657871a7Schristosendforeach(file)
24