-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cmake-format, and a pre-commit hook for it #1755
base: develop
Are you sure you want to change the base?
Conversation
run with command `git ls-files -- '*CMakeLists.txt' | xargs pre-commit run --files`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Format suggestions:
.cmake-format.json
Outdated
"foo": { | ||
"flags": [ | ||
"BAR", | ||
"BAZ" | ||
], | ||
"kwargs": { | ||
"HEADERS": "*", | ||
"SOURCES": "*", | ||
"DEPENDS": "*" | ||
} | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we should list the functions that use CMake argument parsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I meant mostly uses of cmake_parse_arguments
, where the formatting tool can otherwise not differentiate between flags/kwargs and regular arguments
# \param name name for the executable to create (including type | ||
# suffix) \param use_lib_linops Boolean indicating if linking against | ||
# hipsparse/cusparse is necessary \param macro_def preprocessor macro name | ||
# that will be defined during building (to compile for a specific type) All | ||
# remaining arguments will be treated as source files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It destories the format
@@ -14,6 +14,12 @@ repos: | |||
third_party/identify_stream_usage/.*| | |||
include/ginkgo/ginkgo.hpp | |||
) | |||
- repo: https://github.com/cheshirekow/cmake-format-precommit | |||
rev: 'v0.6.13' # The current latest release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is kind of uncontinued project
# \param name base-name for the executable to create \param | ||
# use_lib_linops Boolean indicating if linking against hipsparse/cusparse is | ||
# necessary All remaining arguments will be treated as source files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format issue
# dashboard. The supported runs are: + With or without coverage, requires the | ||
# gcov tool. + With or without address sanitizers. + With or without memory | ||
# sanitizers. + With or without thread sanitizers. + With or without leak | ||
# sanitizers. + With or without undefined behavior (UB) sanitizers. + With or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format issue
elseif((NOT CTEST_MEMORYCHECK_TYPE STREQUAL "NONE" AND NOT CTEST_MEMORYCHECK_TYPE STREQUAL "Valgrind") OR CTEST_BUILD_CONFIGURATION STREQUAL "COVERAGE") | ||
set(GINKGO_CONFIGURE_OPTIONS "-DGINKGO_DEVEL_TOOLS=OFF;-DGINKGO_BUILD_REFERENCE=ON;-DGINKGO_BUILD_OMP=ON;-DGINKGO_BUILD_CUDA=OFF;-DGINKGO_BUILD_HIP=OFF;-DGINKGO_BUILD_SYCL=OFF;-DCMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION}") | ||
set(GINKGO_CONFIGURE_OPTIONS | ||
"-DGINKGO_DEVEL_TOOLS=OFF;-DGINKGO_BUILD_REFERENCE=ON;-DGINKGO_BUILD_OMP=OFF;-DGINKGO_BUILD_CUDA=ON;-DGINKGO_BUILD_HIP=OFF;-DGINKGO_BUILD_SYCL=OFF;-DCMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION};-DCMAKE_CUDA_FLAGS=-lineinfo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not follow column limit
function(ginkgo_extract_dpcpp_version DPCPP_COMPILER GINKGO_DPCPP_VERSION | ||
MACRO_VAR | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit weird to me
set(${GINKGO_DPCPP_VERSION} | ||
"${FOUND_DPCPP_VERSION}" | ||
PARENT_SCOPE | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not exceed 80 char
STATUS | ||
"Skipping ${_LANG}, not supported by build_type_helpers.cmake script" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after STATUS, it has one more indentation, but it does not do that after STRING in line 160
@@ -17,102 +16,116 @@ set(GINKGO_INSTALL_MODULE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Ginkgo/Modules") | |||
# 3. GINKGO_INSTALL_RPATH_DEPENDENCIES : Allows adding any extra paths to the | |||
# RPATH. | |||
# | |||
# @param name the name of the target | |||
# @param ARGN any external dependencies path to be added | |||
# @param name the name of the target @param ARGN any external dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong format
# We separate the library as a workaround to solve this issue | ||
# To make ginkgo still be the major library, we make the original to ginkgo_core in MSVC/shared | ||
# TODO: should think another way to solve it like dllexport or def file | ||
# MSVC: LNK1189 issue CLANG in MSYS2 (MINGW): too many exported symbols We |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong format
This PR adds a pre-commit hook to format CMakeLists,txt files. The actual format can still be discussed. But currently, I just formatted all CMakeLists.txt files with the default style. If necessary, we can adjust the style in the
.cmake-format.json
file.Unfortunately, as develop does not have cmake-format hook, the current format job will not run the cmake-format pre-commit hook yet.