]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: replace deprecated `remove` command with `rm` and pass arg safely
authorViktor Szakats <commit@vsz.me>
Fri, 26 Jun 2026 15:25:16 +0000 (17:25 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 26 Jun 2026 17:01:30 +0000 (19:01 +0200)
All curl-supported CMake versions support the modern method, along with
the `--` marker.

Also:
- make sure to pass `-f` to not fail if the file is missing, as before
  this patch.
- drop now redundant `OUTPUT_QUIET`, `ERROR_QUIET` and error handling
  in `cmake_uninstall`.
- move filename to end of the error message for readability.
- GHA/linux: test these two 'clean' targets in the aws-lc job.

Refs:
https://cmake.org/cmake/help/v4.4/manual/cmake.1.html#cmdoption-cmake-E-arg-remove
https://cmake.org/cmake/help/v3.18/manual/cmake.1.html#run-a-command-line-tool

Closes #22193

.github/workflows/linux.yml
CMake/cmake_uninstall.in.cmake
tests/certs/CMakeLists.txt

index 8d9c1cd55d7006519ebfba8a776af3b35b25f9ea..eab56c180c092c6da78f6454ec6108fe8402cf68 100644 (file)
@@ -79,7 +79,7 @@ jobs:
 
           - name: 'awslc'
             install_packages: libidn2-dev
-            install_steps: awslc
+            install_steps: awslc clean
             generate: -DOPENSSL_ROOT_DIR=/home/runner/awslc -DUSE_ECH=ON -DCMAKE_UNITY_BUILD=OFF -DCURL_DROP_UNUSED=ON -DCURL_PATCHSTAMP=test-patch -DCURL_ENABLE_NTLM=ON
 
           - name: 'boringssl'
@@ -916,6 +916,9 @@ jobs:
         run: |
           if [ "${MATRIX_BUILD}" = 'cmake' ]; then
             cmake --install bld --strip
+            if [[ "${MATRIX_INSTALL_STEPS}" = *'clean'* ]]; then
+              cmake --build bld --target curl_uninstall
+            fi
           else
             make -C bld V=1 install
           fi
@@ -962,6 +965,9 @@ jobs:
           fi
           if [ "${MATRIX_BUILD}" = 'cmake' ]; then
             cmake --build bld --verbose --target "${TEST_TARGET}"
+            if [[ "${MATRIX_INSTALL_STEPS}" = *'clean'* ]]; then
+              cmake --build bld --target clean-certs
+            fi
           else
             make -C bld V=1 "${TEST_TARGET}"
           fi
index 801c4c406e94ee6c7c37a7a847e75219e5d22583..4cc34d9289697d4740d522805e3c3b74f320d1cd 100644 (file)
@@ -35,16 +35,8 @@ 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 remove "$ENV{DESTDIR}${_file}"
-      RESULT_VARIABLE rm_retval
-      OUTPUT_QUIET
-      ERROR_QUIET
-    )
-    if(NOT "${rm_retval}" STREQUAL 0)
-      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${_file}")
-    endif()
+    execute_process(COMMAND "@CMAKE_COMMAND@" -E rm -f -- "$ENV{DESTDIR}${_file}")
   else()
-    message(STATUS "File $ENV{DESTDIR}${_file} does not exist.")
+    message(STATUS "File does not exist: $ENV{DESTDIR}${_file}")
   endif()
 endforeach()
index ebe6fbcfa7fb4d1aee98839056e2684be3983a80..a96593a24e0eaf4e58adde1edced43bf85e3ecf0 100644 (file)
@@ -39,7 +39,7 @@ if(NOT _CURL_SKIP_BUILD_CERTS)
 endif()
 
 add_custom_target(clean-certs
-  COMMAND ${CMAKE_COMMAND} -E remove ${GENERATEDCERTS}
+  COMMAND ${CMAKE_COMMAND} -E rm -f ${GENERATEDCERTS}
     "test-*.csr"
     "test-*.der"
     "test-*.keyenc"