diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2021-10-15 09:22:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-15 09:22:45 +0800 |
| commit | dd0f088aaa4c6bf013643be2d1d8621dbffdb000 (patch) | |
| tree | d848d6ce007d8bb9357c8b99d6a0a39ec41d244e /cpack/fakeroot_fix.cmake | |
| parent | 9e08d1047fa8deeb3ccb3ce9bb11d69e25a52d56 (diff) | |
| parent | eb719a424e6a16fb64209139a32c9f8a7235a929 (diff) | |
| download | psn00bsdk-dd0f088aaa4c6bf013643be2d1d8621dbffdb000.tar.gz | |
Merge pull request #38 from spicyjpeg/cmake
Full CMake support (in place of makefiles)
Diffstat (limited to 'cpack/fakeroot_fix.cmake')
| -rw-r--r-- | cpack/fakeroot_fix.cmake | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cpack/fakeroot_fix.cmake b/cpack/fakeroot_fix.cmake new file mode 100644 index 0000000..e34baa0 --- /dev/null +++ b/cpack/fakeroot_fix.cmake @@ -0,0 +1,32 @@ +# This script works around a bug in CPack's DEB/RPM generator, which causes +# files installed by subprojects (not by the main CMake script) to end up in +# packages alongside the "real" installation directory. It probably happens due +# to CMake running under fakeroot (when invoked by CPack to prepare the files +# to be packaged) and referencing absolute paths, which would explain why the +# entire build directory tree is replicated inside the packages. What this +# script does is simply finding and deleting all directories that do not match +# the installation prefix before CPack generates the package. + +cmake_minimum_required(VERSION 3.21) + +set(_prefix ${CPACK_TEMPORARY_INSTALL_DIRECTORY}${CPACK_PACKAGING_INSTALL_PREFIX}) + +file( + GLOB_RECURSE _entries + LIST_DIRECTORIES ON + ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/* +) + +foreach(_entry IN LISTS _entries) + # Skip the entry if it (or its parent directory) has already been deleted. + if(NOT EXISTS ${_entry}) + continue() + endif() + + # Delete anything whose path doesn't start with the expected prefix. + string(FIND ${_entry} ${_prefix} _index) + if(NOT _index EQUAL 0) + message(NOTICE "Deleting unneeded entry from package: ${_entry}") + file(REMOVE_RECURSE ${_entry}) + endif() +endforeach() |
