浏览代码

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`
Deniz Bahadir 1 年之前
父节点
当前提交
9e67ad47a9
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      Source/cmLocalGenerator.cxx

+ 8 - 1
Source/cmLocalGenerator.cxx

@@ -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"