CMake uninstall

CMake is a great tool when building cross-plattform software. It offers also install target so you can build and install software this way:


# create of-of-source build directory
mkdir bld
cd bld
# run CMake to generate a Makefile
ccmake ..
# Build in 4 cores
make -j 4
# Install into CMAKE_INSTALL_PREFIX (default is /usr/local)
sudo make install

However there is no uninstall target.
But this is no problem as long as you have a shell and the xargs command (part of GNU findutils).

CMake creates a file called install_manifest.txt when executing the install target. This contains a list of all installed files. So for removing them you simply need to execute this command:


# uninstall
xargs rm < install_manifest.txt

Advertisements

2 Responses to “CMake uninstall”


  1. 1 Ahmet October 28, 2016 at 7:43 am

    Unfortunately it is not working for me.

    Ubuntu 16.04 LTS –> CMake 3.6.2 with default gcc-5 compiler (version 5.4.0)

    Following is the output (Part of the Output, since Output is too long):

    rm: cannot remove ‘/usr/local/share/cmake-3.6/Help/generator/Visual’: No such file or directory
    rm: cannot remove ‘Studio’: No such file or directory
    rm: cannot remove ‘7.rst’: No such file or directory
    rm: cannot remove ‘/usr/local/share/cmake-3.6/Help/generator/Eclipse’: No such file or directory …….

    • 2 gergap October 28, 2016 at 11:14 am

      hi,

      it looks like you try to remove file names with spaces, which causes the error.
      I’m wondering why this is in /usr/local/share/cmake. Are you trying to uninstall cmake itself?

      anyway, you should be able to fix this by using \0 as a delimiter for xargs,
      but before you have to convert the file names of install_manifest to use \0.

      cat install_manifest.txt | tr '\n' '\0' | xargs -0 rm

      should work (have not tested)

      regards,
      Gerhard


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: