Skip to content

install(DIRECTORY): Prevent creating empty directories

When using install(DIRECTORY ... [...]), the entire folder structure of the directory to install is reproduced in the destination, even though the subfolders might be empty.

I would suggest to first scan the folder to install, regarding the FILES_MATCHING a PATTERN or REGEX and then copy only these files. Only the non-existing folders in the path of the matched files to copy should be created.

Alternatively introduce a IGNORE_EMPTY_DIRECTORIES variable as suggested by @ben.boeckel, for compatibility reasons.

See details on discourse.cmake.org

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information