Skip to content
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

Improve clang-format check target by showing files which are not correctly formatted #91

Open
dariusarnold opened this issue Nov 27, 2022 · 0 comments

Comments

@dariusarnold
Copy link

Hello, nice work creating/collecting all the examples.

I used your project to integrate clang-format into CMake. Doing that I adapted it slightly and want to suggest this as a possible improvement.
I found that the check target would just error if code was not formatted. In clang-format you can use the --dry--run and --Werror flags to get output of what was not formatted and also getting a sensible return code without grep.
My code for the custom target looks like this:

add_custom_target(clang-format-check
        COMMENT "Checking clang-format changes"
        COMMAND ${ClangFormat_EXECUTABLE}
        --style=file
        --dry-run
        --Werror
        ${ALL_SOURCE_FILES}
        )

The output when run:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant