-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake_uninstall.cmake.in
41 lines (38 loc) · 1.54 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
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND ${CMAKE_COMMAND} "-E" "remove" "\"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file} : ${OUTPUT_VARIABLE}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
get_filename_component(DIRNAME ${file} DIRECTORY)
# file(GLOB RESULT ${DIRNAME}/*)
# list(LENGTH RESULT RES_LEN)
# message(STATUS "Checking ${DIRNAME} [${RESULT}] [${RES_LEN}]")
# if(RES_LEN EQUAL 0)
# # dir is empty [should be removed]
# message(STATUS "Uninstalling ${DIRNAME}")
# execute_process(
# COMMAND ${CMAKE_COMMAND} "-E" "remove_directory" "\"${DIRNAME}\""
# OUTPUT_VARIABLE rm_out
# RESULT_VARIABLE rm_retval
# )
# if(NOT "${rm_retval}" STREQUAL 0)
# message(FATAL_ERROR "Problem when removing ${DIRNAME} : ${OUTPUT_VARIABLE}")
# endif()
# else()
# message(STATUS "Cannot uninstall ${DIRNAME}")
# endif()
endforeach()