Registry Mirror
Skip to content

Conversation

@VijayabaskarR-06

@VijayabaskarR-06 VijayabaskarR-06 commented Oct 7, 2026 •

Copy link
Copy Markdown

Fixes #167.

Adds a "make uninstall" target that removes installed files from all "install_manifest*.txt files and documents it in "doc/install.md".

The approach suggested in the issue only checks "install_manifest.txt", so it does not work for "make installbin" and "make installlib". The new script checks all the manifest files and also handles paths with spaces and dangling symlinks.

It shows an error if a file cannot be removed, such as when it needs sudo. Directories are not removed since they may be shared with other packages.

The target is only added for standalone builds so it will not conflict with an uninstall target in a parent project.

I tested this on Ubuntu 24.04 with libcapnpdev and it was succesfully tested
So fro this I tested with a script in a clean Ubuntu 24.04 container with libcapnpdev installed via apt. It covers normal install, install-bin and install-lib, DESTDIR, and building as a subproject.
and here is the result output for it

uninstall-test-results

Add a "make uninstall" target that removes the files recorded in the
install_manifest*.txt files that install steps write to the build
directory.

A plain "xargs rm < install_manifest.txt" is not enough, because the
"make install-bin" and "make install-lib" targets install single
components, and CMake records those in install_manifest_bin.txt,
install_manifest_lib.txt and install_manifest_common.txt instead.
The script reads all of these, handles paths containing spaces and
dangling symlinks, and fails with an error if a file cannot be removed,
for example when the install step needed sudo.

Manifests list paths without the DESTDIR prefix, so the script prepends
DESTDIR the same way cmake_install.cmake does. This makes "make
uninstall DESTDIR=<dir>" remove a staged install without touching files
installed directly under the install prefix.

The target is only defined for standalone builds, so it does not
conflict with an uninstall target in a parent project that uses
libmultiprocess as a subdirectory.

Fixes bitcoin-core#167
@DrahtBot

DrahtBot commented Oct 7, 2026 •

Copy link
Copy Markdown

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK ryanofsky

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@hebasto

hebasto commented Oct 30, 2026

Copy link
Copy Markdown
Member

cc @purpleKarrot

Comment thread CMakeLists.txt
VERBATIM)
add_dependencies(install-lib multiprocess)

# Makefile target to support "make uninstall". Only defined for standalone

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this really restricted to the "Unix Makefiles" generator?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

re: #374 (comment)

In commit "cmake: Add uninstall target" (7844bd2)

Is this really restricted to the "Unix Makefiles" generator?

No, it's an ordinary custom target. I tried the PR's target and script with the Ninja generator too, and ninja uninstall and cmake --build build --target uninstall work the same way as make uninstall. The comment copies the wording of the "Makefile targets" comment above it, which has the same problem. Maybe say something like:

# Custom target to support "make uninstall" (or "cmake --build . --target
# uninstall" with other generators). Only defined for standalone builds, so it
# does not conflict with an uninstall target in a parent project.

@ryanofsky ryanofsky left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code review ACK 7844bd2, concept -0. The code looks correct and works as described, but I think documenting how to remove the installed files would be a better fix for #167 than adding a target and script that need maintenance. CMake intentionally doesn't provide an uninstall target, and its FAQ suggests the same xargs rm command as the alternative.

The script's main advantage over the xargs rm < install_manifest.txt command I suggested in #167 is that it also handles the install-bin and install-lib manifests and DESTDIR. But the manifests can be handled in the documentation too, for example:

# Run from the build directory. Requires GNU xargs (Linux).
xargs -d '\n' rm -fv < install_manifest.txt         # after "make install"
xargs -d '\n' rm -fv < install_manifest_bin.txt     # after "make install-bin"
xargs -d '\n' rm -fv < install_manifest_lib.txt     # after "make install-lib"
xargs -d '\n' rm -fv < install_manifest_common.txt  # after "make install-bin" or "make install-lib"

I checked that these remove everything installed by each of the install targets, including paths with spaces. DESTDIR installs are usually to a staging directory that can just be deleted.

That said, I'd be happy to merge this if others think it is worthwhile.

I tested the target and script in a small CMake project with the same install components, with Makefiles and Ninja: normal and component installs, DESTDIR, paths with spaces, dangling symlinks, and an unremovable file all behave as described.

The CI runs for this push didn't start any jobs, which looks unrelated to the change, so it would be good to rebase to get a real CI result.

Comment thread CMakeLists.txt
VERBATIM)
add_dependencies(install-lib multiprocess)

# Makefile target to support "make uninstall". Only defined for standalone

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

re: #374 (comment)

In commit "cmake: Add uninstall target" (7844bd2)

Is this really restricted to the "Unix Makefiles" generator?

No, it's an ordinary custom target. I tried the PR's target and script with the Ninja generator too, and ninja uninstall and cmake --build build --target uninstall work the same way as make uninstall. The comment copies the wording of the "Makefile targets" comment above it, which has the same problem. Maybe say something like:

# Custom target to support "make uninstall" (or "cmake --build . --target
# uninstall" with other generators). Only defined for standalone builds, so it
# does not conflict with an uninstall target in a parent project.

Comment thread cmake/Uninstall.cmake
message(FATAL_ERROR "MP_INSTALL_MANIFEST_DIR must be set to the build directory.")
endif()

file(GLOB manifests "${MP_INSTALL_MANIFEST_DIR}/install_manifest*.txt")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In commit "cmake: Add uninstall target" (7844bd2)

Note: since the manifests stay in the build directory, this also picks up manifests from installs to an earlier prefix. I checked this with a small test project using this script: after make install, reconfiguring with a different CMAKE_INSTALL_PREFIX, and make install-lib, make uninstall removes the files from both prefixes. That seems ok since it only removes files this build directory installed, but it might be worth a sentence in doc/install.md saying make uninstall removes files from every install done from the build directory. Separately, it could make sense to delete the manifests after a successful uninstall (file(REMOVE ${manifests}) at the end), so running it a second time says nothing is installed instead of listing every file as not found. Either way is fine with me.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninstall instructions

4 participants