[CMake][Clang] Copy folder without permissions
authorSebastian Neubauer <Sebastian.Neubauer@amd.com>
Thu, 21 Jul 2022 12:06:42 +0000 (14:06 +0200)
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>
Fri, 22 Jul 2022 08:38:54 +0000 (10:38 +0200)
Copying the folder keeps the original permissions by default. This
creates problems when the source folder is read-only, e.g. in a
packaging environment.
Then, the copied folder in the build directory is read-only as well.
Later on, with configure_file, ClangConfig.cmake is copied into that
directory (in the build tree), failing when the directory is read-only.

Fix that problem by copying the folder without keeping the original
permissions.

Differential Revision: https://reviews.llvm.org/D130254

clang/cmake/modules/CMakeLists.txt

index c6f6ce9..c6afdab 100644 (file)
@@ -32,8 +32,10 @@ set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 
 # For compatibility with projects that include(ClangConfig)
 # via CMAKE_MODULE_PATH, place API modules next to it.
+# Copy without source permissions because the source could be read-only
 file(COPY .
   DESTINATION ${clang_cmake_builddir}
+  NO_SOURCE_PERMISSIONS
   FILES_MATCHING PATTERN *.cmake
   PATTERN CMakeFiles EXCLUDE
   )