CMake: Yield error if VCPKG_ROOT variable is missing

...and vcpkg usage was requested.

The user got no further feedback why vcpkg wasn't used despite passing
the -vcpkg configure argument.

Pick-to: 6.8 6.9
Change-Id: Ib43c2045f093c3887a63406e37f37bdd681341cd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Joerg Bornemann 2024-12-30 10:41:53 +01:00
parent 19564e033c
commit fecae6ab1b

View File

@ -152,7 +152,12 @@ function(qt_auto_detect_android)
endfunction()
function(qt_auto_detect_vcpkg)
if(QT_USE_VCPKG AND DEFINED ENV{VCPKG_ROOT})
if(QT_USE_VCPKG)
if(NOT DEFINED ENV{VCPKG_ROOT})
message(FATAL_ERROR
"Usage of vcpkg was requested but the environment variable VCPKG_ROOT is not set."
)
endif()
set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE)