install(FILES): Unable to install a symlink which points to a directory
If you create a symbolic link to a directory and you want to install the link with your package CMake produces an error:
CMake Error at CMakeLists.txt:7 (install):
install FILES given directory
"/Users/jcarl/devel/kitware/test/build/bin.link" to install.
-- Configuring incomplete, errors occurred!
Here is a sample CMakeLists.txt which reproduces the problem.
cmake_minimum_required(VERSION 3.20)
project(InstallSymlink2Directory)
file(MAKE_DIRECTORY package/usr/local/bin)
file(MAKE_DIRECTORY package/opt)
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/package/usr/local/bin" "${CMAKE_CURRENT_BINARY_DIR}/bin.link" SYMBOLIC)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bin.link" DESTINATION "package/opt/" RENAME "bin")
Version
$ cmake --version
cmake version 3.20.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Edited by Brad King