From 876e67c26e42c0c7d2daa41c6871af117ae6bec5 Mon Sep 17 00:00:00 2001 From: autoantwort <41973254+autoantwort@users.noreply.github.com> Date: Thu, 24 Jun 2021 00:30:46 +0200 Subject: [vcpkg.cmake] PREPEND CMAKE_FIND_ROOT_PATH (#17336) * [vcpkg.cmake] PREPEND CMAKE_FIND_ROOT_PATH * [vcpkg.cmake] make PREPEND optional (default off, option VCPKG_PREFER_VCPKG_LIBS) * Apply suggestions from code review Co-authored-by: nicole mazzuca * Update scripts/buildsystems/vcpkg.cmake Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> Co-authored-by: nicole mazzuca --- scripts/buildsystems/vcpkg.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 446e64f23..58d3da956 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -47,6 +47,7 @@ mark_as_advanced(VCPKG_VERBOSE) option(VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON) option(X_VCPKG_APPLOCAL_DEPS_SERIALIZED "(experimental) Add USES_TERMINAL to VCPKG_APPLOCAL_DEPS to force serialization." OFF) option(X_VCPKG_APPLOCAL_DEPS_INSTALL "(experimental) Automatically copy dependencies into the install target directory for executables." 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) # Manifest options and settings if(NOT DEFINED VCPKG_MANIFEST_DIR) @@ -379,29 +380,35 @@ set(_VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}" CACHE PATH "The directory which contains the installed libraries for each triplet" FORCE) +if(VCPKG_PREFER_SYSTEM_LIBS) + set(Z_VCPKG_PATH_LIST_OP APPEND) +else() + set(Z_VCPKG_PATH_LIST_OP PREPEND) +endif() + if(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$" OR NOT DEFINED CMAKE_BUILD_TYPE) #Debug build: Put Debug paths before Release paths. - list(APPEND CMAKE_PREFIX_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_PREFIX_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" ) - list(APPEND CMAKE_LIBRARY_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_LIBRARY_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link" ) - list(APPEND CMAKE_FIND_ROOT_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_FIND_ROOT_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" ) else() #Release build: Put Release paths before Debug paths. Debug Paths are required so that CMake generates correct info in autogenerated target files. - list(APPEND CMAKE_PREFIX_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_PREFIX_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" ) - list(APPEND CMAKE_LIBRARY_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_LIBRARY_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link" ) - list(APPEND CMAKE_FIND_ROOT_PATH + list(${Z_VCPKG_PATH_LIST_OP} CMAKE_FIND_ROOT_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" ) -- cgit v1.2.3