From 512d62f7ee117ccf3176a8acf96a0a6ce7a22dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Bornemann?= Date: Wed, 10 May 2023 02:08:28 +0200 Subject: [PATCH] [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. --- scripts/buildsystems/vcpkg.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 15496ce45a..739495fb7e 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -56,12 +56,13 @@ if(VCPKG_PREFER_SYSTEM_LIBS) endif() # Manifest options and settings +set(Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE "${VCPKG_MANIFEST_DIR}") if(NOT DEFINED VCPKG_MANIFEST_DIR) 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() -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) if(DEFINED VCPKG_MANIFEST_DIR AND NOT VCPKG_MANIFEST_DIR STREQUAL "") @@ -392,16 +393,16 @@ if(NOT Z_VCPKG_ROOT_DIR) endif() if(DEFINED VCPKG_INSTALLED_DIR) - # do nothing + set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${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) - set(VCPKG_INSTALLED_DIR "${CMAKE_BINARY_DIR}/vcpkg_installed") + set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${CMAKE_BINARY_DIR}/vcpkg_installed") else() - set(VCPKG_INSTALLED_DIR "${Z_VCPKG_ROOT_DIR}/installed") + set(Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${Z_VCPKG_ROOT_DIR}/installed") endif() -set(VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}" +set(VCPKG_INSTALLED_DIR "${Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE}" CACHE PATH "The directory which contains the installed libraries for each triplet" FORCE) set(_VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}"