Skip to content

Apache DataFusion SQL Query Engine

ARROW-4918: [C++] Add cmake-format to pre-commit

Uwe L. Korn1534c88d6268
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e5f5c59ff6..8823164fc2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -37,6 +37,12 @@ repos:
types:
- file
- rust
+ - id: cmake-format
+ name: cmake-format
+ language: python
+ entry: bash -c "pip install cmake-format && python run-cmake-format.py --check"
+ entry: echo
+ files: ^(.*/CMakeLists.txt|.*.cmake)$
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: v1.2.3
hooks:
diff --git a/run-cmake-format.py b/run-cmake-format.py
index 1dfff5c2be..4617fb9f5a 100755
--- a/run-cmake-format.py
+++ b/run-cmake-format.py
@@ -25,7 +25,32 @@ import sys
patterns = [
'cpp/CMakeLists.txt',
- 'cpp/cmake_modules/FindGFlags.cmake',
+ # Keep an explicit list of files to format as we don't want to reformat
+ # files we imported from other location.
+ 'cpp/cmake_modules/BuildUtils.cmake',
+ 'cpp/cmake_modules/FindArrowCuda.cmake',
+ 'cpp/cmake_modules/FindBrotli.cmake',
+ 'cpp/cmake_modules/FindClangTools.cmake',
+ 'cpp/cmake_modules/FindDoubleConversion.cmake',
+ 'cpp/cmake_modules/FindGLOG.cmake',
+ 'cpp/cmake_modules/FindGandiva.cmake',
+ 'cpp/cmake_modules/FindInferTools.cmake',
+ 'cpp/cmake_modules/FindLLVM.cmake',
+ 'cpp/cmake_modules/FindLz4.cmake',
+ 'cpp/cmake_modules/FindParquet.cmake',
+ 'cpp/cmake_modules/FindPlasma.cmake',
+ 'cpp/cmake_modules/FindRE2.cmake',
+ 'cpp/cmake_modules/FindRapidJSONAlt.cmake',
+ 'cpp/cmake_modules/FindSnappyAlt.cmake',
+ 'cpp/cmake_modules/FindThrift.cmake',
+ 'cpp/cmake_modules/FindZSTD.cmake',
+ 'cpp/cmake_modules/Findc-aresAlt.cmake',
+ 'cpp/cmake_modules/FindgRPCAlt.cmake',
+ 'cpp/cmake_modules/FindgflagsAlt.cmake',
+ 'cpp/cmake_modules/Findjemalloc.cmake',
+ 'cpp/cmake_modules/SetupCxxFlags.cmake',
+ 'cpp/cmake_modules/ThirdpartyToolchain.cmake',
+ 'cpp/cmake_modules/san-config.cmake',
'cpp/src/**/CMakeLists.txt',
'cpp/tools/**/CMakeLists.txt',
'java/gandiva/CMakeLists.txt',