[cmake] honor $VCPKG_ROOT from env (#83003)

This commit is contained in:
Tess Rosania
2025-09-23 07:33:25 -07:00
committed by GitHub
parent 42ece09d52
commit c7dbaf7e20
2 changed files with 13 additions and 11 deletions
-6
View File
@@ -24,9 +24,6 @@
"displayName": "Windows x64 MSVC",
"description": "Target Windows (64-bit) with the Visual Studio development environment.",
"generator": "Visual Studio 17 2022",
"environment": {
"VCPKG_ROOT": "C:/vcpkg"
},
"cacheVariables": {
"DYNAMIC_LINKING": "False",
"CURSES": "True", "LOCALIZE": "True", "TILES": "False", "SOUND": "False", "TESTS": "True",
@@ -55,9 +52,6 @@
"description": "Target Windows (64-bit) with the Visual Studio development environment.",
"generator": "Visual Studio 17 2022",
"inherits": "windows-tiles-sounds-x64",
"environment": {
"VCPKG_ROOT": "C:/vcpkg"
},
"cacheVariables": {
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
+13 -5
View File
@@ -85,9 +85,17 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# Where is vcpkg.json ?
set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features)
set(VCPKG_ROOT "" CACHE PATH "Path to VCPKG installation")
if (NOT $ENV{VCPKG_ROOT} STREQUAL "")
include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
elseif(NOT $CACHE{VCPKG_ROOT} STREQUAL "")
include($CACHE{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}" CACHE PATH "Path to VCPKG installation")
if(NOT VCPKG_ROOT)
set(VCPKG_ROOT "C:/vcpkg" CACHE PATH "Path to VCPKG installation" FORCE)
endif()
set(_vcpkg_toolchain "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(NOT EXISTS "${_vcpkg_toolchain}")
message(FATAL_ERROR
"Could not find vcpkg toolchain file at:\n ${_vcpkg_toolchain}\n"
"Check that VCPKG_ROOT points to a valid vcpkg checkout "
"(it should contain scripts/buildsystems/vcpkg.cmake).")
endif()
include("${_vcpkg_toolchain}")