File: Uninstall.cmake.in

package info (click to toggle)
poselib 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,592 kB
  • sloc: cpp: 15,023; python: 182; sh: 85; makefile: 10
file content (68 lines) | stat: -rw-r--r-- 2,182 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Based on:
#   http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
#

# 'delete_empty_folder' function
function(delete_empty_folder DIR)
  if(NOT EXISTS ${DIR})
    return()
  endif()

  # check if folder is empty
  file(GLOB RESULT "${DIR}/*")
  list(LENGTH RESULT RES_LEN)
  if(RES_LEN EQUAL 0)
    message(STATUS "Delete empty folder ${DIR}")
    file(REMOVE_RECURSE ${DIR})
  else()
    # message(STATUS "${DIR} is not empty! It won't be removed.")
    # message(STATUS "FILES = ${RESULT}")
  endif()
endfunction(delete_empty_folder)

# find 'install_manifest.txt'
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif()

# remove files from 'install_manifest.txt'
message(STATUS "")
message(STATUS "Removing files from 'install_manifest.txt'")
file(READ "@CMAKE_CURRENT_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}")
    exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
      OUTPUT_VARIABLE rm_out
      RETURN_VALUE rm_retval)
    if(NOT "${rm_retval}" STREQUAL 0)
      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
    endif()
  else()
    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
  endif()

  # create list of folders
  get_filename_component(FOLDER ${file} DIRECTORY)
  set(FOLDERS ${FOLDERS} ${FOLDER})
endforeach(file)


# remove empty folders
message(STATUS "")
message(STATUS "Removing empty folders")

list(REMOVE_DUPLICATES FOLDERS)
foreach(dir ${FOLDERS})
#   message(STATUS ${dir})
  delete_empty_folder(${dir})
#   message(STATUS "")
endforeach(dir)

delete_empty_folder("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
delete_empty_folder("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@")
delete_empty_folder("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/cmake")
delete_empty_folder("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@")
message(STATUS "")