From 88d85916f24ededa1b9f90b52c4c5d18af2c8072 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 26 Jun 2026 22:56:02 +0200 Subject: [PATCH] cmake: minor improvements to `cmake_uninstall.in.cmake` - reduce log noise by showing 'Uninstalling' message only if the file exists. (and a different message otherwise) - replace cmake `rm` command with `file(REMOVE)`. For efficiency. Show manual message if the file could not be deleted. Ref: https://cmake.org/cmake/help/v3.18/command/file.html#remove Follow-up to 6d008352c667799beecb1ab1dfbc408c415d018c #22193 - reduce log noise by showing 'Uninstalled' only if the deletion was successful. (and a different message otherwise) - display `DESTDIR` env value if set. - drop checking, setting and showing `CMAKE_INSTALL_PREFIX`. The value was never predefined, also not used, besides showing it, and showing it is misleading because `--prefix` may override the configure-time value, and also superfluous because the filenames are showing the actual prefix anyway. Follow-up to 27e2a4733c3321fb0b1a127360e8e96bc3d4ae53 Closes #22201 --- CMake/cmake_uninstall.in.cmake | 16 ++++++++++------ CMakeLists.txt | 4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMake/cmake_uninstall.in.cmake b/CMake/cmake_uninstall.in.cmake index c7fd8008e1..30e812b124 100644 --- a/CMake/cmake_uninstall.in.cmake +++ b/CMake/cmake_uninstall.in.cmake @@ -26,18 +26,22 @@ 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@") +set(_destdir "$ENV{DESTDIR}") +if(NOT _destdir STREQUAL "") + message(STATUS "DESTDIR environment: ${_destdir}") 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}") + set(_target "${_destdir}${_file}") if(IS_SYMLINK "${_target}" OR EXISTS "${_target}") - execute_process(COMMAND "@CMAKE_COMMAND@" -E rm -f -- "${_target}") + file(REMOVE "${_target}") + if(IS_SYMLINK "${_target}" OR EXISTS "${_target}") + message(STATUS "Failed to delete: ${_target}") + else() + message(STATUS "Uninstalled: ${_target}") + endif() else() message(STATUS "File does not exist: ${_target}") endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index c0071f1a07..5929b741ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2452,9 +2452,7 @@ if(NOT CURL_DISABLE_INSTALL) DESTINATION ${_install_cmake_dir}) if(NOT TARGET curl_uninstall) - # Consumed variables: - # CMAKE_COMMAND - # CMAKE_INSTALL_PREFIX + # Consumed variable: # PROJECT_BINARY_DIR configure_file( "${PROJECT_SOURCE_DIR}/CMake/cmake_uninstall.in.cmake"