mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
By passing to clang-tidy the C compiler with `--target` and sysroot
options, if any.
Fixing (GHA/windows, linux-mingw, CM clang-tidy):
```
lib/curl_setup.h:841:10: error: 'io.h' file not found [clang-diagnostic-error]
841 | #include <io.h>
| ^~~~~~
Found compiler error(s).
FAILED: [code=1] tests/server/CMakeFiles/servers-clang-tidy bld/tests/server/CMakeFiles/servers-clang-tidy
cd tests/server && /usr/bin/clang-tidy --config-file=.clang-tidy.yml
--warnings-as-errors=* --checks=-clang-diagnostic-unused-function first.c getpart.c util.c dnsd.c [...]
-- <-D-options> <-I-options> <cflags>
```
For reference, this is CMake's built-in clang-tidy invocation:
```
/usr/local/bin/cmake -E __run_co_compile --tidy="/usr/bin/clang-tidy;--config-file=.clang-tidy.yml;
--warnings-as-errors=*;--extra-arg-before=--driver-mode=gcc" --source=lib/curl_fopen.c
-- /usr/bin/clang --target=x86_64-w64-mingw32 <-D-options> <-I-options> <cflags>
```
Also:
- bump cmakelint `--max-statements`. Needs 59 after this patch.
- use undocumented CMake variables:
- `CMAKE_C_COMPILE_OPTIONS_TARGET` for `--target=`
- `CMAKE_C_COMPILE_OPTIONS_SYSROOT` for `--sysroot=`
Cherry-picked from #20631
Closes #20640
|
||
|---|---|---|
| .. | ||
| cmake_uninstall.in.cmake | ||
| curl-config.in.cmake | ||
| CurlSymbolHiding.cmake | ||
| CurlTests.c | ||
| FindBrotli.cmake | ||
| FindCares.cmake | ||
| FindGnuTLS.cmake | ||
| FindGSS.cmake | ||
| FindLDAP.cmake | ||
| FindLibbacktrace.cmake | ||
| FindLibgsasl.cmake | ||
| FindLibidn2.cmake | ||
| FindLibpsl.cmake | ||
| FindLibrtmp.cmake | ||
| FindLibssh2.cmake | ||
| FindLibssh.cmake | ||
| FindLibuv.cmake | ||
| FindMbedTLS.cmake | ||
| FindNettle.cmake | ||
| FindNGHTTP2.cmake | ||
| FindNGHTTP3.cmake | ||
| FindNGTCP2.cmake | ||
| FindQuiche.cmake | ||
| FindRustls.cmake | ||
| FindWolfSSL.cmake | ||
| FindZstd.cmake | ||
| Macros.cmake | ||
| OtherTests.cmake | ||
| PickyWarnings.cmake | ||
| unix-cache.cmake | ||
| Utilities.cmake | ||
| win32-cache.cmake | ||