acxz | 6f6e939 | 2020-07-30 21:16:50 -0400 | [diff] [blame] | 1 | # Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake |
| 2 | |
| 3 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") |
| 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") |
| 5 | endif() |
| 6 | |
| 7 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) |
| 8 | string(REGEX REPLACE "\n" ";" files "${files}") |
| 9 | foreach(file ${files}) |
| 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") |
| 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") |
| 12 | exec_program( |
Henry Schreiner | ed6de12 | 2020-08-01 23:47:47 -0400 | [diff] [blame] | 13 | "@CMAKE_COMMAND@" ARGS |
| 14 | "-E remove \"$ENV{DESTDIR}${file}\"" |
acxz | 6f6e939 | 2020-07-30 21:16:50 -0400 | [diff] [blame] | 15 | OUTPUT_VARIABLE rm_out |
Henry Schreiner | ed6de12 | 2020-08-01 23:47:47 -0400 | [diff] [blame] | 16 | RETURN_VALUE rm_retval) |
acxz | 6f6e939 | 2020-07-30 21:16:50 -0400 | [diff] [blame] | 17 | if(NOT "${rm_retval}" STREQUAL 0) |
| 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") |
| 19 | endif() |
| 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") |
| 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") |
| 22 | endif() |
| 23 | endforeach() |