set CMake policy CMP0087 for X_VCPKG_APPLOCAL_DEPS_INSTALL (#15874)

Without this, X_VCPKG_APPLOCAL_DEPS_INSTALL does not work and
CMake prints this warning at the configure step:

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0087 is not set: Install CODE|SCRIPT allow the use of generator
expressions.  Run "cmake --help-policy CMP0087" for policy details.  Use
the cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

https://cmake.org/cmake/help/latest/policy/CMP0087.html
This commit is contained in:
Be 2021-01-28 13:43:14 -08:00 committed by GitHub
parent 3c466eb80c
commit 31608174fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -529,6 +529,10 @@ function(x_vcpkg_install_local_dependencies)
foreach(TARGET IN LISTS __VCPKG_APPINSTALL_TARGETS)
get_target_property(TARGETTYPE ${TARGET} TYPE)
if(NOT TARGETTYPE STREQUAL "INTERFACE_LIBRARY")
# Install CODE|SCRIPT allow the use of generator expressions
if(POLICY CMP0087)
cmake_policy(SET CMP0087 NEW)
endif()
install(CODE "message(\"-- Installing app dependencies for ${TARGET}...\")
execute_process(COMMAND \"${_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
-targetBinary \"\${CMAKE_INSTALL_PREFIX}/${__VCPKG_APPINSTALL_DESTINATION}/$<TARGET_FILE_NAME:${TARGET}>\"