mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
cmake: improve clang-tidy test command-line reproduction
- also query `INTERFACE_COMPILE_DEFINITIONS` and
`INTERFACE_COMPILE_OPTIONS`.
To further sync clang-tidy manual command-lines with the C compiler
command-lines generated by CMake. In practice this adds `-I` options
(via `INTERFACE_COMPILE_OPTIONS`) to the end of the command-line for
dependency header directories. It does not change the outcome of
clang-tidy runs.
- limit querying `COMPILE_DEFINITIONS` and `COMPILE_OPTIONS` to the top
target, the test itself. To not include options such as
`-DCURL_HIDDEN_SYMBOLS` and `-fvisibility=hidden` (when set) via
the libcurl shared lib.
To sync with the actual C compiler command-line.
- drop redundant `unset()`.
- rename local function to be more specific.
Follow-up to d9386a2f8e #20759
Closes #20829
This commit is contained in:
parent
c6cfb2a2f3
commit
009facd232
@ -110,20 +110,16 @@ endmacro()
|
|||||||
|
|
||||||
# Internal: Recurse into target libraries and collect their include directories
|
# Internal: Recurse into target libraries and collect their include directories
|
||||||
# and macro definitions.
|
# and macro definitions.
|
||||||
macro(curl_collect_target_options _target)
|
macro(curl_collect_target_compile_options _target)
|
||||||
get_target_property(_val ${_target} COMPILE_DEFINITIONS)
|
get_target_property(_val ${_target} INTERFACE_COMPILE_DEFINITIONS)
|
||||||
if(_val)
|
if(_val)
|
||||||
list(APPEND _definitions ${_val})
|
list(APPEND _definitions ${_val})
|
||||||
endif()
|
endif()
|
||||||
get_target_property(_val ${_target} INCLUDE_DIRECTORIES)
|
|
||||||
if(_val)
|
|
||||||
list(APPEND _includes ${_val})
|
|
||||||
endif()
|
|
||||||
get_target_property(_val ${_target} INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(_val ${_target} INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
if(_val)
|
if(_val)
|
||||||
list(APPEND _incsys ${_val})
|
list(APPEND _incsys ${_val})
|
||||||
endif()
|
endif()
|
||||||
get_target_property(_val ${_target} COMPILE_OPTIONS)
|
get_target_property(_val ${_target} INTERFACE_COMPILE_OPTIONS)
|
||||||
if(_val)
|
if(_val)
|
||||||
list(APPEND _options ${_val})
|
list(APPEND _options ${_val})
|
||||||
endif()
|
endif()
|
||||||
@ -131,7 +127,7 @@ macro(curl_collect_target_options _target)
|
|||||||
if(_val)
|
if(_val)
|
||||||
foreach(_lib IN LISTS _val)
|
foreach(_lib IN LISTS _val)
|
||||||
if(TARGET "${_lib}")
|
if(TARGET "${_lib}")
|
||||||
curl_collect_target_options(${_lib})
|
curl_collect_target_compile_options(${_lib})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
@ -159,7 +155,7 @@ function(curl_add_clang_tidy_test_target _target_clang_tidy _target)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Collect macro definitions and header directories applying to the directory
|
# Collect options applying to the directory
|
||||||
get_directory_property(_val COMPILE_DEFINITIONS)
|
get_directory_property(_val COMPILE_DEFINITIONS)
|
||||||
if(_val)
|
if(_val)
|
||||||
list(APPEND _definitions ${_val})
|
list(APPEND _definitions ${_val})
|
||||||
@ -172,10 +168,23 @@ function(curl_add_clang_tidy_test_target _target_clang_tidy _target)
|
|||||||
if(_val)
|
if(_val)
|
||||||
list(APPEND _options ${_val})
|
list(APPEND _options ${_val})
|
||||||
endif()
|
endif()
|
||||||
unset(_val)
|
|
||||||
|
# Collect options applying to the target
|
||||||
|
get_target_property(_val ${_target} COMPILE_DEFINITIONS)
|
||||||
|
if(_val)
|
||||||
|
list(APPEND _definitions ${_val})
|
||||||
|
endif()
|
||||||
|
get_target_property(_val ${_target} INCLUDE_DIRECTORIES)
|
||||||
|
if(_val)
|
||||||
|
list(APPEND _includes ${_val})
|
||||||
|
endif()
|
||||||
|
get_target_property(_val ${_target} COMPILE_OPTIONS)
|
||||||
|
if(_val)
|
||||||
|
list(APPEND _options ${_val})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Collect header directories and macro definitions from lib dependencies
|
# Collect header directories and macro definitions from lib dependencies
|
||||||
curl_collect_target_options(${_target})
|
curl_collect_target_compile_options(${_target})
|
||||||
|
|
||||||
list(REMOVE_ITEM _definitions "")
|
list(REMOVE_ITEM _definitions "")
|
||||||
string(REPLACE ";" ";-D" _definitions ";${_definitions}")
|
string(REPLACE ";" ";-D" _definitions ";${_definitions}")
|
||||||
|
|||||||
@ -72,8 +72,8 @@ cd "$(dirname "$0")"/..
|
|||||||
--min-statement-spacing 1 \
|
--min-statement-spacing 1 \
|
||||||
--max-statement-spacing 2 \
|
--max-statement-spacing 2 \
|
||||||
--max-returns 6 \
|
--max-returns 6 \
|
||||||
--max-branches 15 \
|
--max-branches 20 \
|
||||||
--max-arguments 5 \
|
--max-arguments 5 \
|
||||||
--max-localvars 15 \
|
--max-localvars 15 \
|
||||||
--max-statements 85 \
|
--max-statements 95 \
|
||||||
--
|
--
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user