forked from mendersoftware/mender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmake_uninstall.cmake.in
42 lines (40 loc) · 1.66 KB
/
cmake_uninstall.cmake.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if(CMAKE_INSTALL_COMPONENT)
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
else()
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANIFEST}")
# It's a bit silly to install right before uninstalling, but it appears to be
# the only way to generate the manifest file that we need. We are going to
# delete the exact same files that we install, so there is no ill behavior
# here, just using a few more CPU cycles and adding some empty directories.
if(CMAKE_INSTALL_COMPONENT)
execute_process(
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --component ${CMAKE_INSTALL_COMPONENT}
OUTPUT_VARIABLE install_output
ERROR_VARIABLE install_output
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE install_output
ERROR_VARIABLE install_output
)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANIFEST}")
message(FATAL_ERROR "Cannot find install manifest, even after attempting to generate it: ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANIFEST}: ${install_output}")
endif()
endif()
# TODO: doesn't remove directories created for installed files
file(READ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANIFEST}" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E rm -f "$ENV{DESTDIR}${file}"
RESULT_VARIABLE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
endforeach()