export(PACKAGE): terminal log does not mention installation to package registry
The command make install
writes a terminal log like this:
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/cmake/LibHeinzConfig.cmake
-- Installing: /usr/local/cmake/LibHeinzConfigVersion.cmake
-- Up-to-date: /usr/local/include/heinz/Complex.h
-- Up-to-date: /usr/local/include/heinz/Vectors3D.h
The list of installed files is also written to the file install_manifest.txt
.
To some users, it may come as a bad surprise that this list is incomplete. Besides copying the above four files, make install
does more thing: It writes a short file containing the path of the current build directory to ~/.cmake/packages
.
In consequence, against reasonable expectation,
cat install_manifest.txt | sudo xargs rm
is not sufficient to entirely purge an installation.
Consider a dependent project that has the following line in its CMakeLists.txt
:
find_package(LibHeinz REQUIRED)
message(STATUS "LibHeinz: found=${LibHeinz_FOUND}, include_dirs=${LibHeinz_INCLUDE_DIR}, "
"version=${LibHeinz_VERSION}")
After uninstalling LibHeinz from my system, I would expect CMake to fail. Instead, it reports
-- LibHeinz: found=1, include_dirs=/usr/local/include, version=0.1
and happily proceeds. Only at compile time it turns out that there are no LibHeinz headers in /usr/local/include
.
According to https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-registry, there are ways to deactivate the package registry - but first you have to know about it.
I suggest to add a line like
-- Installing: ~/.cmake/packages/LibHeinz/06f3aa7153189f9fb32c34a6f2eed16f
to the terminal output of make install
, and also to add the registry file to install_manifest.txt
.