[vcpkg tool] Add optional tracing of find_package (#27982)

* Add tracing of find_package

* Doc

* Unset new vars
This commit is contained in:
Kai Pastor 2022-12-01 22:39:31 +01:00 committed by GitHub
parent c4d7348057
commit 73b415a0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -224,3 +224,8 @@ Defaults to `OFF`.
This variable can be set to a list of feature flags to pass to the vcpkg tool during automatic installation to opt-in to experimental behavior.
See the `--feature-flags=` command line option for more information.
### `VCPKG_TRACE_FIND_PACKAGE`
When this option is turned on, every call to `find_package` is printed.
Nested calls (e.g. via `find_dependency`) are indented according to nesting depth.

View File

@ -746,6 +746,7 @@ if(X_VCPKG_APPLOCAL_DEPS_INSTALL)
endfunction()
endif()
option(VCPKG_TRACE_FIND_PACKAGE "Trace calls to find_package()" OFF)
if(NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME)
set(VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package)
endif()
@ -754,6 +755,14 @@ endif()
# so perfect forwarding is not important
set(z_vcpkg_find_package_backup_id "0")
macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name)
if(VCPKG_TRACE_FIND_PACKAGE)
string(REPEAT " " "${z_vcpkg_find_package_backup_id}" z_vcpkg_find_package_indent)
string(JOIN " " z_vcpkg_find_package_argn ${ARGN})
message(STATUS "${z_vcpkg_find_package_indent}find_package(${z_vcpkg_find_package_package_name} ${z_vcpkg_find_package_argn})")
unset(z_vcpkg_find_package_argn)
unset(z_vcpkg_find_package_indent)
endif()
math(EXPR z_vcpkg_find_package_backup_id "${z_vcpkg_find_package_backup_id} + 1")
set(z_vcpkg_find_package_package_name "${z_vcpkg_find_package_package_name}")
set(z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_ARGN "${ARGN}")