Skip to content

Commit 2c0f529

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Enable CMAKE linter (#255)
Summary: Pull Request resolved: #255 Enable CMAKE-linter Reviewed By: digantdesai Differential Revision: D49105432 fbshipit-source-id: 02819be63c0e4633bce4d62329c1f3d468955091
1 parent 05167ef commit 2c0f529

File tree

7 files changed

+43
-5
lines changed

7 files changed

+43
-5
lines changed

.cmakelintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
filter=+whitespace/extra,-whitespace/indent

.lintrunner.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,34 @@ init_command = [
9191
'--requirement=requirements-lintrunner.txt',
9292
]
9393
is_formatter = true
94+
95+
[[linter]]
96+
code = 'CMAKE'
97+
include_patterns = [
98+
"**/*.cmake",
99+
"**/*.cmake.in",
100+
"**/CMakeLists.txt",
101+
]
102+
exclude_patterns = [
103+
'third-party/**',
104+
'**/third-party/**',
105+
]
106+
command = [
107+
'python',
108+
'-m',
109+
'lintrunner_adapters',
110+
'run',
111+
'cmake_linter',
112+
'--config=.cmakelintrc',
113+
'--',
114+
'@{{PATHSFILE}}',
115+
]
116+
init_command = [
117+
'python',
118+
'-m',
119+
'lintrunner_adapters',
120+
'run',
121+
'pip_init',
122+
'--dry-run={{DRYRUN}}',
123+
'--requirement=requirements-lintrunner.txt',
124+
]

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
5959
# `examples/custom_ops/custom_ops_2.cpp`.
6060
option(
6161
REGISTER_EXAMPLE_CUSTOM_OP
62-
"Register whether custom op 1 (my_ops::mul3) or custom op 2 (my_ops::mul4) or no custom op at all."
62+
"Register whether custom op 1 (my_ops::mul3) or custom op 2 (my_ops::mul4) \
63+
or no custom op at all."
6364
OFF)
6465

6566
# Option to register quantized ops with quantized kernels. See

backends/xnnpack/cmake/Dependencies.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
# The logic is copied from https://github.com/pytorch/pytorch/blob/main/cmake/Dependencies.cmake
7+
# The logic is copied from
8+
# https://github.com/pytorch/pytorch/blob/main/cmake/Dependencies.cmake
89
set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
910

1011
# --- cpuinfo

build/Utils.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ function(kernel_link_options target_name)
3737
target_link_options(
3838
${target_name}
3939
INTERFACE
40-
"SHELL:LINKER:--whole-archive $<TARGET_FILE:${target_name}> LINKER:--no-whole-archive"
40+
"SHELL:LINKER:--whole-archive \
41+
$<TARGET_FILE:${target_name}> \
42+
LINKER:--no-whole-archive"
4143
)
4244
endfunction()
4345

kernels/quantized/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ message("Generated files ${gen_command_sources}")
4545
# Build a AOT library to register quantized ops into PyTorch.
4646
set(_quantized_sources
4747
${_quantized_kernels__srcs}
48-
${EXECUTORCH_ROOT}/runtime/core/exec_aten/util/tensor_util_aten.cpp # This is a
49-
# hack
48+
${EXECUTORCH_ROOT}/runtime/core/exec_aten/util/tensor_util_aten.cpp # This
49+
# is a hack
5050
)
5151
gen_custom_ops_aot_lib("quantized_ops_aot_lib" "${_quantized_sources}")
5252

requirements-lintrunner.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ ufmt==2.0.1
1313
usort==1.0.5
1414

1515
clang-format==12.0.1
16+
17+
cmakelint==1.4.1

0 commit comments

Comments
 (0)