Skip to content

cmake: replace deprecated remove command with rm and pass arg safely#22193

Closed
vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:cm-rm
Closed

cmake: replace deprecated remove command with rm and pass arg safely#22193
vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:cm-rm

Conversation

@vszakats

@vszakats vszakats commented Jun 26, 2026

Copy link
Copy Markdown
Member

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

@vszakats vszakats added the cmake label Jun 26, 2026
@vszakats vszakats changed the title cmake: replace deprecated remove command with rm and pass arg securely cmake: replace deprecated remove command with rm and pass arg safely Jun 26, 2026
@github-actions github-actions Bot added the CI Continuous Integration label Jun 26, 2026
vszakats added 5 commits June 26, 2026 18:39
```
cmake -E rm test-ca.cacert test-ca.crt test-ca.key
  test-client-cert.crl test-client-cert.crt test-client-cert.key
  test-client-cert.pem test-client-cert.pub.der test-client-cert.pub.pem
  test-client-eku-only.crl test-client-eku-only.crt
  test-client-eku-only.key test-client-eku-only.pem
  test-client-eku-only.pub.der test-client-eku-only.pub.pem
  test-localhost-san-first.crl test-localhost-san-first.crt
  test-localhost-san-first.key test-localhost-san-first.pem
  test-localhost-san-first.pub.der test-localhost-san-first.pub.pem
  test-localhost-san-last.crl test-localhost-san-last.crt
  test-localhost-san-last.key test-localhost-san-last.pem
  test-localhost-san-last.pub.der test-localhost-san-last.pub.pem
  test-localhost.crl test-localhost.crt test-localhost.key
  test-localhost.nn.crl test-localhost.nn.crt test-localhost.nn.key
  test-localhost.nn.pem test-localhost.nn.pub.der
  test-localhost.nn.pub.pem test-localhost.pem test-localhost.pub.der
  test-localhost.pub.pem test-localhost0h.crl test-localhost0h.crt
  test-localhost0h.key test-localhost0h.pem test-localhost0h.pub.der
  test-localhost0h.pub.pem test-*.csr test-*.der test-*.keyenc
  test-ca.cnt* test-ca.db* test-ca.raw* test-ca.srl
CMake Error: File to remove does not exist and force is not set: test-client-cert.pub.der
CMake Error: File to remove does not exist and force is not set: test-client-eku-only.pub.der
CMake Error: File to remove does not exist and force is not set: test-localhost-san-first.pub.der
CMake Error: File to remove does not exist and force is not set: test-localhost-san-last.pub.der
CMake Error: File to remove does not exist and force is not set: test-localhost.nn.pub.der
CMake Error: File to remove does not exist and force is not set: test-localhost.pub.der
CMake Error: File to remove does not exist and force is not set: test-localhost0h.pub.der
```
@vszakats vszakats closed this in 6d00835 Jun 26, 2026
@vszakats vszakats deleted the cm-rm branch June 26, 2026 17:02
@vszakats vszakats requested a review from Copilot June 26, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes CMake “clean/uninstall” behaviors by switching from the deprecated cmake -E remove to cmake -E rm, improving argument handling, and adding CI coverage for the clean targets in the Linux GitHub Actions workflow.

Changes:

  • Replace cmake -E remove with cmake -E rm -f for cert cleanup and uninstall script behavior.
  • Add -- end-of-options marker for safer argument passing in the uninstall script.
  • Extend the Linux GHA aws-lc CMake job to exercise curl_uninstall and clean-certs targets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/certs/CMakeLists.txt Switch clean target to cmake -E rm -f for generated cert artifacts.
CMake/cmake_uninstall.in.cmake Update uninstall removal command to cmake -E rm -f -- and adjust messaging/handling.
.github/workflows/linux.yml Add a CMake aws-lc matrix entry that runs uninstall and cert cleanup targets in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/certs/CMakeLists.txt
Comment thread CMake/cmake_uninstall.in.cmake
vszakats added a commit that referenced this pull request Jun 27, 2026
- 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 6d00835 #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 27e2a47

Closes #22201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI Continuous Integration cmake tests

Development

Successfully merging this pull request may close these issues.

2 participants