aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorautoantwort <41973254+autoantwort@users.noreply.github.com>2021-06-24 00:30:46 +0200
committerGitHub <noreply@github.com>2021-06-23 15:30:46 -0700
commit876e67c26e42c0c7d2daa41c6871af117ae6bec5 (patch)
treef4d140ed392db631906fb677e23b72fd39deb71c /scripts
parent2ed44b4546ecc764c81db4fd16ea19d19ea0449d (diff)
downloadvcpkg-876e67c26e42c0c7d2daa41c6871af117ae6bec5.tar.gz
vcpkg-876e67c26e42c0c7d2daa41c6871af117ae6bec5.zip
[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 <mazzucan@outlook.com> * Update scripts/buildsystems/vcpkg.cmake Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/buildsystems/vcpkg.cmake19
1 files changed, 13 insertions, 6 deletions
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"
)