Skip to content

Commit 12f046e

Browse files
committed
Fix checksummed manifest when DESTDIR is set
- Fixes #665
1 parent 6a1e30d commit 12f046e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmake/InstallFileManifest.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# This script will create and install an install manifest, including SHA256 hashes of each installed file
23
# Variables passed from CMake must be set with `install(CODE "set(...)")`
34

@@ -6,7 +7,7 @@ message(STATUS "Generating SHA256 checksumed receipt for all installed assets")
67
# Set receipt install destination
78
set(RECEIPT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
89

9-
# Mimic cmake_install.cmake's handlin of components
10+
# Mimic cmake_install.cmake's handling of components
1011
if(CMAKE_INSTALL_COMPONENT)
1112
set(HASHED_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.SHA256.txt")
1213
else()
@@ -16,10 +17,15 @@ endif()
1617
# Clean out any old install manifest on re-installation, if it exists
1718
file(REMOVE "${CMAKE_BINARY_DIR}/${HASHED_INSTALL_MANIFEST}")
1819

20+
if(DEFINED ENV{DESTDIR})
21+
get_filename_component(ABS_DESTDIR "$ENV{DESTDIR}" ABSOLUTE)
22+
else()
23+
set(ABS_DESTDIR "")
24+
endif()
1925
# Loop over files computing hashes
2026
foreach(file IN LISTS CMAKE_INSTALL_MANIFEST_FILES)
21-
file(SHA256 "${file}" _file_sha256)
22-
file(RELATIVE_PATH FILE_REL_PATH "${RECEIPT_INSTALL_DIR}" "${file}")
27+
file(SHA256 "$ENV{DESTDIR}${file}" _file_sha256)
28+
file(RELATIVE_PATH FILE_REL_PATH "${ABS_DESTDIR}${RECEIPT_INSTALL_DIR}" "${ABS_DESTDIR}${file}")
2329
file(APPEND "${CMAKE_BINARY_DIR}/${HASHED_INSTALL_MANIFEST}" "${_file_sha256} ${FILE_REL_PATH}\n")
2430
endforeach()
2531
file(APPEND "${CMAKE_BINARY_DIR}/${HASHED_INSTALL_MANIFEST}"

0 commit comments

Comments
 (0)