Merge topic 'rel-src-cleanup' into release-4.0

57a24181ed clang-tidy: Do not require config file if not running clang-tidy
aa42ba1ac8 gitattributes: Do not export pre-commit config file in source archives

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10371
diff --git a/.gitattributes b/.gitattributes
index 8151ec8..0e7ab06 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4,6 +4,7 @@
 .clang-tidy      export-ignore
 .codespellrc     export-ignore
 .editorconfig    export-ignore
+.pre-commit-config.yaml export-ignore
 .typos.toml      export-ignore
 
 # Custom attribute to mark sources as using our C code style.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1a12cb..749404d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -325,8 +325,8 @@
     unset(clang_tidy_module_sha1)
   endif()
 
+  configure_file(.clang-tidy .clang-tidy COPYONLY)
 endif()
-configure_file(.clang-tidy .clang-tidy COPYONLY)
 
 
 option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt
index 5e6ef0a..e377733 100644
--- a/Utilities/CMakeLists.txt
+++ b/Utilities/CMakeLists.txt
@@ -17,5 +17,7 @@
   add_subdirectory(Release/WiX)
 endif()
 
-# Make sure generated files use the same clang-tidy checks (none).
-configure_file(.clang-tidy .clang-tidy COPYONLY)
+if(CMake_RUN_CLANG_TIDY)
+  # Make sure generated files use the same clang-tidy checks (none).
+  configure_file(.clang-tidy .clang-tidy COPYONLY)
+endif()