CPack source tarball generator does not handle symlinks to directories properly
When generating a source tarball for a project containing symlinks to directories, the symlinks are replaced by empty directories in the tarball. This behaviour is a consequence of !4637 (merged) ; before that the target directory would be copied recursively.
Minimal example:
.
├─ CMakeLists.txt
└─ data/
├─ bar -> foo/
└─ foo/
└─ foo.txt
CMakeLists.txt:
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(cpack-symlinks VERSION 0.1 LANGUAGES NONE)
install(DIRECTORY data DESTINATION share/cpack-symlinks)
include(CPack)
Commands:
cmake <source-dir>
make package_source
tar tvf cpack-symlinks-0.1-Source.tar.gz
Expected output:
drwxr-x--- maoi/ma 0 2021-03-04 14:03 cpack-symlinks-0.1-Source/data/
drwxr-x--- maoi/ma 0 2021-03-04 14:03 cpack-symlinks-0.1-Source/data/foo/
-rw-r----- maoi/ma 11 2021-03-04 14:00 cpack-symlinks-0.1-Source/data/foo/foo.txt
lrwxrwxrwx maoi/ma 0 2021-03-04 14:03 cpack-symlinks-0.1-Source/data/bar -> foo
-rw-r----- maoi/ma 172 2021-03-04 14:02 cpack-symlinks-0.1-Source/CMakeLists.txt
Actual output:
drwxr-x--- maoi/ma 0 2021-03-04 14:10 cpack-symlinks-0.1-Source/data/
drwxr-x--- maoi/ma 0 2021-03-04 14:10 cpack-symlinks-0.1-Source/data/foo/
-rw-r----- maoi/ma 11 2021-03-04 14:00 cpack-symlinks-0.1-Source/data/foo/foo.txt
drwxr-x--- maoi/ma 0 2021-03-04 14:00 cpack-symlinks-0.1-Source/data/bar/
-rw-r----- maoi/ma 172 2021-03-04 14:02 cpack-symlinks-0.1-Source/CMakeLists.txt