[vcpkg.cmake] Fix CMP0126 warnings (#23784) (#29969)

When running CMake 3.21 or newer in trace or debug mode, vcpkg.cmake
would trigger the CMP0126 warning for VCPKG_MANIFEST_DIR and
VCPKG_INSTALLED_DIR.

The regular variable was used to set the initial value of the cache
variable of the same name. This patch adds the regular variables
Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE and
Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE that are used to initialize their
respective cache variables.
This commit is contained in:
Jörg Bornemann 2023-05-10 02:08:28 +02:00 committed by GitHub
parent e1cdda71f6
commit 512d62f7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,12 +56,13 @@ if(VCPKG_PREFER_SYSTEM_LIBS)
endif() endif()
# Manifest options and settings # Manifest options and settings
set(Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE "${VCPKG_MANIFEST_DIR}")
if(NOT DEFINED VCPKG_MANIFEST_DIR) if(NOT DEFINED VCPKG_MANIFEST_DIR)
if(EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json") if(EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json")
set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}") set(Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE "${CMAKE_SOURCE_DIR}")
endif() endif()
endif() endif()
set(VCPKG_MANIFEST_DIR "${VCPKG_MANIFEST_DIR}" set(VCPKG_MANIFEST_DIR "${Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE}"
CACHE PATH "The path to the vcpkg manifest directory." FORCE) CACHE PATH "The path to the vcpkg manifest directory." FORCE)
if(DEFINED VCPKG_MANIFEST_DIR AND NOT VCPKG_MANIFEST_DIR STREQUAL "") if(DEFINED VCPKG_MANIFEST_DIR AND NOT VCPKG_MANIFEST_DIR STREQUAL "")
@ -392,16 +393,16 @@ if(NOT Z_VCPKG_ROOT_DIR)
endif() endif()
if(DEFINED VCPKG_INSTALLED_DIR) if(DEFINED VCPKG_INSTALLED_DIR)
# do nothing set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${VCPKG_INSTALLED_DIR}")
elseif(DEFINED _VCPKG_INSTALLED_DIR) elseif(DEFINED _VCPKG_INSTALLED_DIR)
set(VCPKG_INSTALLED_DIR "${_VCPKG_INSTALLED_DIR}") set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${_VCPKG_INSTALLED_DIR}")
elseif(VCPKG_MANIFEST_MODE) elseif(VCPKG_MANIFEST_MODE)
set(VCPKG_INSTALLED_DIR "${CMAKE_BINARY_DIR}/vcpkg_installed") set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${CMAKE_BINARY_DIR}/vcpkg_installed")
else() else()
set(VCPKG_INSTALLED_DIR "${Z_VCPKG_ROOT_DIR}/installed") set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${Z_VCPKG_ROOT_DIR}/installed")
endif() endif()
set(VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}" set(VCPKG_INSTALLED_DIR "${Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE}"
CACHE PATH CACHE PATH
"The directory which contains the installed libraries for each triplet" FORCE) "The directory which contains the installed libraries for each triplet" FORCE)
set(_VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}" set(_VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}"