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