xref: /freebsd/contrib/libevent/cmake/Uninstall.cmake.in (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1# 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(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
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    exec_program(
13      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
14      OUTPUT_VARIABLE rm_out
15      RETURN_VALUE rm_retval
16      )
17    if(NOT "${rm_retval}" STREQUAL 0)
18      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
19    endif(NOT "${rm_retval}" STREQUAL 0)
20  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
21    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
22  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
23endforeach(file)
24