From c916abaa0ddd5d1e248834c0bd5aea81c7ed5165 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Wed, 8 Jul 2020 00:01:01 +0200 Subject: [PATCH] [vcpkg.cmake] Support toolchains that set CMAKE_FIND_ROOT_PATH_MODE_* variables to ONLY (#11753) --- scripts/buildsystems/vcpkg.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 10be7a423..96f847190 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -230,6 +230,16 @@ else() #Release build: Put Release paths before Debug paths. Debug Paths are req ) endif() +# If one CMAKE_FIND_ROOT_PATH_MODE_* variables is set to ONLY, to make sure that ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} +# and ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug are searched, it is not sufficient to just add them to CMAKE_FIND_ROOT_PATH, +# as CMAKE_FIND_ROOT_PATH specify "one or more directories to be prepended to all other search directories", so to make sure that +# the libraries are searched as they are, it is necessary to add "/" to the CMAKE_PREFIX_PATH +if(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE STREQUAL "ONLY" OR + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY STREQUAL "ONLY" OR + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE STREQUAL "ONLY") + list(APPEND CMAKE_PREFIX_PATH "/") +endif() + set(VCPKG_CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}) file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)