curl/CMake/cmake_uninstall.in.cmake
Viktor Szakats b8fa725df3
cmake: dedupe expressions into local vars in cmake_uninstall.in.cmake
Also: use `IN LISTS` syntax.

Follow-up to 27e2a4733c

Closes #22194
2026-06-26 19:42:16 +02:00

44 lines
1.7 KiB
CMake

#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set(_manifest "@PROJECT_BINARY_DIR@/install_manifest.txt")
if(NOT EXISTS "${_manifest}")
message(FATAL_ERROR "Cannot find install manifest: ${_manifest}")
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
endif()
message(${CMAKE_INSTALL_PREFIX})
file(READ "${_manifest}" _files)
string(REGEX REPLACE "\n" ";" _files "${_files}")
foreach(_file IN LISTS _files)
set(_target "$ENV{DESTDIR}${_file}")
message(STATUS "Uninstalling ${_target}")
if(IS_SYMLINK "${_target}" OR EXISTS "${_target}")
execute_process(COMMAND "@CMAKE_COMMAND@" -E rm -f -- "${_target}")
else()
message(STATUS "File does not exist: ${_target}")
endif()
endforeach()