Deprecated VCPKG_PREFER_SYSTEM_LIBS (#26449)

This commit is contained in:
Kai Pastor 2022-08-23 21:07:33 +02:00 committed by GitHub
parent 698ca0211d
commit 02fcf92f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 19 deletions

View File

@ -213,6 +213,8 @@ This variable can be set to a list of additional command line parameters to pass
### `VCPKG_PREFER_SYSTEM_LIBS`
**This feature has been deprecated. Use empty overlay ports instead.**
This variable controls whether vcpkg will append instead of prepend its paths to `CMAKE_PREFIX_PATH`, `CMAKE_LIBRARY_PATH` and `CMAKE_FIND_ROOT_PATH` so that vcpkg libraries/packages are found after toolchain/system libraries/packages.
Defaults to `OFF`.

View File

@ -51,6 +51,9 @@ option(X_VCPKG_APPLOCAL_DEPS_SERIALIZED "(experimental) Add USES_TERMINAL to VCP
# requires CMake 3.14
option(X_VCPKG_APPLOCAL_DEPS_INSTALL "(experimental) Automatically copy dependencies into the install target directory for executables. Requires CMake 3.14." OFF)
option(VCPKG_PREFER_SYSTEM_LIBS "Appends the vcpkg paths to CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH and CMAKE_FIND_ROOT_PATH so that vcpkg libraries/packages are found after toolchain/system libraries/packages." OFF)
if(VCPKG_PREFER_SYSTEM_LIBS)
message(WARNING "VCPKG_PREFER_SYSTEM_LIBS has been deprecated. Use empty overlay ports instead.")
endif()
# Manifest options and settings
if(NOT DEFINED VCPKG_MANIFEST_DIR)

View File

@ -221,14 +221,10 @@ foreach(executable IN LISTS cmake_commands)
CMAKE_COMMAND "${executable}"
OPTIONS
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_PREFIX_PATH=SYSTEM_LIBS" # for testing VCPKG_PREFER_SYSTEM_LIBS
"-DVCPKG_PREFER_SYSTEM_LIBS=OFF"
)
test_cmake_project(NAME "debug"
CMAKE_COMMAND "${executable}"
OPTIONS
"-DCMAKE_BUILD_TYPE=Debug"
"-DCMAKE_PREFIX_PATH=SYSTEM_LIBS" # for testing VCPKG_PREFER_SYSTEM_LIBS
"-DVCPKG_PREFER_SYSTEM_LIBS=ON"
)
endforeach()

View File

@ -11,21 +11,6 @@ else()
message(STATUS "CMake version check: success (actual: ${CMAKE_VERSION})")
endif()
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
list(FIND CMAKE_PREFIX_PATH "SYSTEM_LIBS" system_libs)
list(FIND CMAKE_PREFIX_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" vcpkg)
if(system_libs LESS 0)
message(SEND_ERROR "VCPKG_PREFER_SYSTEM_LIBS check: failed (Cannot find SYSTEM_LIBS in CMAKE_PREFIX_PATH.)")
elseif(vcpkg LESS 0)
message(SEND_ERROR "VCPKG_PREFER_SYSTEM_LIBS check: failed (Cannot find vcpkg path in CMAKE_PREFIX_PATH.")
elseif(VCPKG_PREFER_SYSTEM_LIBS AND system_libs GREATER vcpkg)
message(SEND_ERROR "VCPKG_PREFER_SYSTEM_LIBS check: failed (actual: ${VCPKG_PREFER_SYSTEM_LIBS}, but vcpkg paths are before system paths in CMAKE_PREFIX_PATH.)")
elseif(NOT VCPKG_PREFER_SYSTEM_LIBS AND system_libs LESS vcpkg)
message(SEND_ERROR "VCPKG_PREFER_SYSTEM_LIBS check: failed (actual: ${VCPKG_PREFER_SYSTEM_LIBS}, but vcpkg paths are after system paths in CMAKE_PREFIX_PATH.)")
else()
message(STATUS "VCPKG_PREFER_SYSTEM_LIBS check: success (actual: ${VCPKG_PREFER_SYSTEM_LIBS})")
endif()
# add_library overload
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib.c" "int lib_unused() { return 1; }")
add_library(lib "${CMAKE_CURRENT_BINARY_DIR}/lib.c")