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

target_disable_clang_tidy(fmt) does not really help #147

Open
ClausKlein opened this issue Sep 2, 2022 · 5 comments
Open

target_disable_clang_tidy(fmt) does not really help #147

ClausKlein opened this issue Sep 2, 2022 · 5 comments
Labels
help wanted Extra attention is needed impossible

Comments

@ClausKlein
Copy link
Contributor

ClausKlein commented Sep 2, 2022

ninja
# ...
/Users/clausklein/.cache/CPM/fmt/15c05aa781ab44fa13a906fe5737c1d14e5edee9/include/fmt/format.h:3036:51: error: all parameters should be named in a function [hicpp-named-parameter,readability-named-parameter,-warnings-as-errors]
constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
                                                  ^
                                                   /*unused*/
/Users/clausklein/.cache/CPM/fmt/15c05aa781ab44fa13a906fe5737c1d14e5edee9/include/fmt/format.h:3043:62: error: parameter name 's' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
FMT_DEPRECATED constexpr auto operator"" _format(const char* s, size_t n)
                                                             ^
/Users/clausklein/Workspace/cpp/ModernCmakeStarter/source/greeter.cpp:4:1: error: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace,-warnings-as-errors]
using namespace greeter;
^
58184 warnings generated.
Suppressed 56453 warnings (56449 in non-user code, 4 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1018 warnings treated as errors
ninja: build stopped: subcommand failed.
Claus-iMac:build-ModernCmakeStarter-Debug clausklein$ builddriver ninja
builddriver executing: 'ninja'
Compilation FAILED in 6.547162 seconds
Number of warnings: 0
Number of errors: 1018
Last Error:
  Message: "do not use namespace using-directives; use using-declarations instead [google-build-using-namespace,-warnings-as-errors]"
  Path: /Users/clausklein/Workspace/cpp/ModernCmakeStarter/source/greeter.cpp
  Line Number: 4
  Column: 1
For full log, please open: /var/folders/wb/ckvxxgls5db7qyhqq4y5_l1c0000gq/T/build-snfb9p3a.log
Claus-iMac:build-ModernCmakeStarter-Debug clausklein$ ninja -nv
[1/4] /usr/local/Cellar/cmake/3.24.1/bin/cmake -E __run_co_compile --launcher=/usr/local/bin/ccache --tidy="/usr/local/opt/llvm/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-warnings-as-errors=*;-extra-arg=-std=c++20;--extra-arg-before=--driver-mode=g++" --source=/Users/clausklein/Workspace/cpp/ModernCmakeStarter/source/greeter.cpp -- /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -DFMT_LOCALE -I/Users/clausklein/.cache/CPM/fmt/15c05aa781ab44fa13a906fe5737c1d14e5edee9/include -isystem /Users/clausklein/Workspace/cpp/ModernCmakeStarter/include -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fcolor-diagnostics -std=c++20 -MD -MT _deps/greeter-build/CMakeFiles/greeter.dir/source/greeter.cpp.o -MF _deps/greeter-build/CMakeFiles/greeter.dir/source/greeter.cpp.o.d -o _deps/greeter-build/CMakeFiles/greeter.dir/source/greeter.cpp.o -c /Users/clausklein/Workspace/cpp/ModernCmakeStarter/source/greeter.cpp
[2/4] : && /usr/local/Cellar/cmake/3.24.1/bin/cmake -E rm -f _deps/greeter-build/libgreeter.a && /usr/bin/ar qc _deps/greeter-build/libgreeter.a  _deps/greeter-build/CMakeFiles/greeter.dir/source/greeter.cpp.o && /usr/bin/ranlib _deps/greeter-build/libgreeter.a && /usr/local/Cellar/cmake/3.24.1/bin/cmake -E touch _deps/greeter-build/libgreeter.a && :
[3/4] : && /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  standalone/CMakeFiles/GreeterStandalone.dir/source/main.cpp.o -o standalone/GreeterStandalone  _deps/greeter-build/libgreeter.a  _deps/fmt-build/libfmtd.a && :
[4/4] : && /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  test/CMakeFiles/GreeterTests.dir/source/main.cpp.o test/CMakeFiles/GreeterTests.dir/source/greeter.cpp.o -o test/GreeterTests  _deps/greeter-build/libgreeter.a  _deps/fmt-build/libfmtd.a && :
Claus-iMac:build-ModernCmakeStarter-Debug clausklein$ 

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar
@ClausKlein
Copy link
Contributor Author

@aminya
Copy link
Owner

aminya commented Sep 3, 2022

Clang tidy returns the warnings from those headers if your config file includes all headers.

@ClausKlein
Copy link
Contributor Author

Yes, the only way I know to prevent this is to patch the CMake generated compile_commands.json file:

Claus-iMac:ModernCmakeStarter clausklein$ make -n check
perl -i.bak -p -e 's#-W[-\w]+(=\d)?\b##g;' -e 's#-I(/Users/clausklein/.cache/CPM)#-isystem $1#g;' ./build-ModernCmakeStarter-Debug/compile_commands.json
run-clang-tidy -p ./build-ModernCmakeStarter-Debug /Users/clausklein/Workspace/cpp/ModernCmakeStarter
Claus-iMac:ModernCmakeStarter clausklein$ 

@aminya
Copy link
Owner

aminya commented Sep 3, 2022

What does this change?

@aminya aminya added help wanted Extra attention is needed impossible labels Sep 3, 2022
@ClausKlein
Copy link
Contributor Author

ClausKlein commented Sep 4, 2022

What does this change?

I use CMP.cmake to fetch my dependencies. With perl script, I replace all -I include path to CMP cache to -isystem include path. And I delete all -W options because some gcc warnings are not valid vor clang.

When you use vpkg or conan the imported CMake config packages use implizit this -isystem include path.

Background info: I use the CPM_SOURCE_CACHE environment variable in my makefile!

perl -i.bak -p -e 's#-W[-\w]+(=\d)?\b##g;' -e 's#-I(${CPM_SOURCE_CACHE})#-isystem $$1#g;' $(BUILD_DIR)/compile_commands.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed impossible
Projects
None yet
Development

No branches or pull requests

2 participants