cmLocalGenerator: Support arbitrary component name when installing

The generated `cmake_install.cmake` script no longer blindly tries to
create files `install_manifest_<component-name>.txt` that partly
consists of the verbatim name of a component, which might contain
characters that are not supported on the platform / filesystem.
Instead, if the component's name contains a (possibly) problematic
character its MD5 hash will be used:
`install_manifest_<component-hash>.txt`
This commit is contained in:
Deniz Bahadir
2024-05-01 19:20:32 +02:00
parent 04ce020bf7
commit 9e67ad47a9

View File

@@ -717,8 +717,15 @@ void cmLocalGenerator::GenerateInstallRules()
/* clang-format off */
fout <<
"if(CMAKE_INSTALL_COMPONENT)\n"
" set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
" if(CMAKE_INSTALL_COMPONENT MATCHES \"^[a-zA-Z0-9_.+-]+$\")\n"
" set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
"${CMAKE_INSTALL_COMPONENT}.txt\")\n"
" else()\n"
" string(MD5 CMAKE_INST_COMP_HASH \"${CMAKE_INSTALL_COMPONENT}\")\n"
" set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
"${CMAKE_INST_COMP_HASH}.txt\")\n"
" unset(CMAKE_INST_COMP_HASH)\n"
" endif()\n"
"else()\n"
" set(CMAKE_INSTALL_MANIFEST \"install_manifest.txt\")\n"
"endif()\n"