]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: dedupe expressions into local vars in `cmake_uninstall.in.cmake`
authorViktor Szakats <commit@vsz.me>
Fri, 26 Jun 2026 15:00:07 +0000 (17:00 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 26 Jun 2026 17:42:16 +0000 (19:42 +0200)
Also: use `IN LISTS` syntax.

Follow-up to 27e2a4733c3321fb0b1a127360e8e96bc3d4ae53

Closes #22194

CMake/cmake_uninstall.in.cmake

index 4cc34d9289697d4740d522805e3c3b74f320d1cd..c7fd8008e19cbeec4fb8e3f75a0f479548f998e5 100644 (file)
@@ -21,8 +21,9 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
-if(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
-  message(FATAL_ERROR "Cannot find install manifest: @PROJECT_BINARY_DIR@/install_manifest.txt")
+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)
@@ -30,13 +31,14 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
 endif()
 message(${CMAKE_INSTALL_PREFIX})
 
-file(READ "@PROJECT_BINARY_DIR@/install_manifest.txt" _files)
+file(READ "${_manifest}" _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 rm -f -- "$ENV{DESTDIR}${_file}")
+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: $ENV{DESTDIR}${_file}")
+    message(STATUS "File does not exist: ${_target}")
   endif()
 endforeach()