xref: /aosp_15_r20/external/bcc/cmake/CmakeUninstall.cmake.in (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1# SPDX-License-Identifier: GPL-2.0-or-later
2# Copyright (C) 2022 Rong Tao
3#
4function(UninstallManifest manifest)
5if(NOT EXISTS "${manifest}")
6  message(FATAL_ERROR "Cannot find install manifest: ${manifest}")
7endif()
8
9file(READ "${manifest}" files)
10string(REGEX REPLACE "\n" ";" files "${files}")
11foreach(file ${files})
12  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
13  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
14    exec_program(
15      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
16      OUTPUT_VARIABLE rm_out
17      RETURN_VALUE rm_retval
18      )
19    if(NOT "${rm_retval}" STREQUAL 0)
20      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
21    endif()
22  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
23    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
24  endif()
25endforeach()
26endfunction()
27
28UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest.txt")
29UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest_python_bcc.txt")
30