[vcpkg] Add VCPKG_SUPPRESS_INSTALLED_LIBRARIES_WARNING and VCPKG_OVERRIDE_FIND_PACKAGE_NAME parameters to the vcpkg toolchain. (#9996)

VCPKG_SUPPRESS_INSTALLED_LIBRARIES_WARNING - Silences warning about lacking installed libraries for the current triplet
VCPKG_OVERRIDE_FIND_PACKAGE_NAME - Enables cooperation with other tooling that may want to hook find_package
This commit is contained in:
Robert Schumacher 2020-02-09 14:40:13 -08:00 committed by GitHub
parent f7fb56decd
commit 039098c954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,7 +122,7 @@ if(NOT DEFINED _VCPKG_ROOT_DIR)
endif()
set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed)
if(NOT EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" AND NOT _CMAKE_IN_TRY_COMPILE)
if(NOT EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" AND NOT _CMAKE_IN_TRY_COMPILE AND NOT VCPKG_SUPPRESS_INSTALLED_LIBRARIES_WARNING)
message(WARNING "There are no libraries installed for the Vcpkg triplet ${VCPKG_TARGET_TRIPLET}.")
endif()
@ -233,7 +233,10 @@ function(add_library name)
endif()
endfunction()
macro(find_package name)
if(NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME)
set(VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package)
endif()
macro(${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} name)
string(TOLOWER "${name}" _vcpkg_lowercase_name)
if(EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/${_vcpkg_lowercase_name}/vcpkg-cmake-wrapper.cmake")
set(ARGS "${ARGV}")