Skip to content

Commit 202fd9a

Browse files
committed
Add hashing script and sha256 output to uninstall
1 parent 72c7958 commit 202fd9a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

cmake/hash-installed.cmake.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Adapted from http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F May 1, 2014
2+
3+
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
4+
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
5+
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
6+
7+
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
8+
string(REGEX REPLACE "\n" ";" files "${files}")
9+
file(WRITE "@CMAKE_BINARY_DIR@/sha256_install_manifest.txt" "")
10+
foreach(file ${files})
11+
if(IS_SYMLINK $ENV{DESTDIR}${file})
12+
list(APPEND symbolic_links ${file})
13+
endif()
14+
file(SHA256 $ENV{DESTDIR}${file} ${file}_sha256)
15+
message(STATUS "${${file}_sha256} $ENV{DESTDIR}${file}")
16+
file(APPEND "@CMAKE_BINARY_DIR@/sha256_install_manifest.txt" "${${file}_sha256} $ENV{DESTDIR}${file}\n")
17+
endforeach()
18+
message(STATUS "Symbolic links: ${symbolic_links}")

cmake/uninstall.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
66

77
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
88
string(REGEX REPLACE "\n" ";" files "${files}")
9+
foreach(file ${files})
10+
if(NOT IS_SYMLINK $ENV{DESTDIR}${file})
11+
file(SHA256 $ENV{DESTDIR}${file} ${file}_sha256)
12+
message(STATUS "${${file}_sha256} $ENV{DESTDIR}${file}")
13+
else()
14+
message(STATUS "$ENV{DESTDIR}${file} is a symbolic link.")
15+
endif()
16+
endforeach()
917
foreach(file ${files})
1018
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
1119
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")

0 commit comments

Comments
 (0)