Skip to content

Commit

Permalink
[vcpkg.cmake] Fix CMP0126 warnings (#23784)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jobor committed Mar 3, 2023
1 parent 64fabc9 commit de49ecb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down Expand Up @@ -386,16 +387,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}"
Expand Down

0 comments on commit de49ecb

Please sign in to comment.