-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* format cmake files to adhere to linting rules * cmake linting workflow/action * cmake clang-tidy: wrap include dir var in quotation
- Loading branch information
Showing
8 changed files
with
183 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# options affecting formatting | ||
format: | ||
# how wide to allow formatted cmake files | ||
line_width: 100 | ||
# how many spaces to tab for indent | ||
tab_size: 4 | ||
# if true, separate flow control names from their parentheses | ||
separate_ctrl_name_with_space: true # currently ignored by cmake-lint | ||
# if true, separate function names from parentheses with a | ||
separate_fn_name_with_space: false # currently ignored by cmake-lint | ||
# if a statement is wrapped to more than one line, than dangle | ||
# the closing parenthesis on its own line. | ||
dangle_parens: false # currently ignored by cmake-lint | ||
# Format command names consistently as 'lower' or 'upper' case | ||
# 'canonical': like in official documentation | ||
command_case: 'canonical' # currently ignored by cmake-lint | ||
# Format keywords consistently as 'lower' or 'upper' case | ||
keyword_case: 'upper' # currently ignored by cmake-lint | ||
# options affecting comment reflow and formatting | ||
markup: | ||
# enable comment markup parsing and reflow | ||
enable_markup: false | ||
# options affecting linter | ||
lint: | ||
# list of lint codes to disable | ||
# C0113: Missing COMMENT in statement which allows it | ||
disabled_codes: ['C0113'] | ||
# regular expression pattern describing valid function names | ||
function_pattern: '[a-z_]+' | ||
# regular expression pattern describing valid names for private variables | ||
# WEIRD: strangely named "directory variable name" in lint output | ||
private_var_pattern: '_[0-9A-Z_]+' | ||
# regular expression pattern describing valid names for public variables (strangely named "directories"?) | ||
# WEIRD: strangely named "directory variable name" in lint output | ||
public_var_pattern: '[0-9A-Z]+' | ||
# regular expression pattern describing valid macro names | ||
macro_pattern: '[a-z_]+' | ||
# regular expression pattern describing valid names for function/macro | ||
# arguments and loop variables | ||
argument_var_pattern: '[A-Z][A-Z0-9_]+' | ||
# require no more than this many newlines between statements | ||
max_statement_spacing: 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: cmake-format linting | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- '**/CMakeLists.txt' | ||
- '**.cmake' | ||
- '**.cmake.in' | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- '**/CMakeLists.txt' | ||
- '**.cmake' | ||
- '**.cmake.in' | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repository | ||
uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- name: install cmakelang | ||
run: python3 -m pip install -U cmakelang | ||
- name: run cmake-lint | ||
run: python3 -m cmakelang.lint CMakeLists.txt src/CMakeLists.txt data/CMakeLists.txt lang/CMakeLists.txt src/chkjson/CMakeLists.txt tools/format/CMakeLists.txt tools/clang-tidy-plugin/CMakeLists.txt cmake_uninstall.cmake.in -c .cmake-format.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") | ||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") | ||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") | ||
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") | ||
message(FATAL_ERROR | ||
"Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") | ||
endif () | ||
|
||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" FILE_LIST) | ||
string(REGEX REPLACE "\n" ";" FILE_LIST "${FILE_LIST}") | ||
foreach (FILE_NAME ${FILE_LIST}) | ||
message(STATUS "Uninstalling \"$ENV{DESTDIR}${FILE_NAME}\"") | ||
if (EXISTS "$ENV{DESTDIR}${FILE_NAME}") | ||
exec_program( | ||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${FILE_NAME}\"" | ||
OUTPUT_VARIABLE RM_OUT | ||
RETURN_VALUE RM_RETVAL) | ||
if ("${RM_RETVAL}" STREQUAL 0) | ||
else () | ||
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${FILE_NAME}\"") | ||
endif () | ||
else () | ||
message(STATUS "File \"$ENV{DESTDIR}${FILE_NAME}\" does not exist.") | ||
endif () | ||
endforeach () | ||
|
||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) | ||
STRING(REGEX REPLACE "\n" ";" files "${files}") | ||
FOREACH(file ${files}) | ||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") | ||
IF(EXISTS "$ENV{DESTDIR}${file}") | ||
EXEC_PROGRAM( | ||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" | ||
OUTPUT_VARIABLE rm_out | ||
RETURN_VALUE rm_retval | ||
) | ||
IF("${rm_retval}" STREQUAL 0) | ||
ELSE("${rm_retval}" STREQUAL 0) | ||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") | ||
ENDIF("${rm_retval}" STREQUAL 0) | ||
ELSE(EXISTS "$ENV{DESTDIR}${file}") | ||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") | ||
ENDIF(EXISTS "$ENV{DESTDIR}${file}") | ||
ENDFOREACH(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.