From 16ebf7b9b83ea79020ed6caa39ea3301e7890de1 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Wed, 30 Mar 2022 02:12:24 +0200 Subject: [PATCH] [vcpkg.cmake] don't clobber cmake program path (#23755) * more filtering of tool paths. * test it in CI * only use tools/* and tools/*/bin * debugging * test removal of tools/* if tools/*/bin is available * fix variable naming * cleanup * revert ports/qtdeclarative/portfile.cmake --- scripts/buildsystems/vcpkg.cmake | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 138963133e..ce3a9bbe1d 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -538,15 +538,24 @@ if(VCPKG_SETUP_CMAKE_PROGRAM_PATH) set(tools_base_path "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/tools") endif() list(APPEND CMAKE_PROGRAM_PATH "${tools_base_path}") - file(GLOB_RECURSE Z_VCPKG_TOOLS_DIRS LIST_DIRECTORIES true "${tools_base_path}/*") - file(GLOB_RECURSE Z_VCPKG_TOOLS_FILES LIST_DIRECTORIES false "${tools_base_path}/*") + file(GLOB Z_VCPKG_TOOLS_DIRS LIST_DIRECTORIES true "${tools_base_path}/*") + file(GLOB Z_VCPKG_TOOLS_FILES LIST_DIRECTORIES false "${tools_base_path}/*") + file(GLOB Z_VCPKG_TOOLS_DIRS_BIN LIST_DIRECTORIES true "${tools_base_path}/*/bin") + file(GLOB Z_VCPKG_TOOLS_FILES_BIN LIST_DIRECTORIES false "${tools_base_path}/*/bin") list(REMOVE_ITEM Z_VCPKG_TOOLS_DIRS ${Z_VCPKG_TOOLS_FILES} "") # need at least one item for REMOVE_ITEM if CMake <= 3.19 - list(FILTER Z_VCPKG_TOOLS_DIRS EXCLUDE REGEX "/debug/") + list(REMOVE_ITEM Z_VCPKG_TOOLS_DIRS_BIN ${Z_VCPKG_TOOLS_FILES_BIN} "") + string(REPLACE "/bin" "" Z_VCPKG_TOOLS_DIRS_TO_REMOVE "${Z_VCPKG_TOOLS_DIRS_BIN}") + list(REMOVE_ITEM Z_VCPKG_TOOLS_DIRS ${Z_VCPKG_TOOLS_DIRS_TO_REMOVE} "") + list(APPEND Z_VCPKG_TOOLS_DIRS ${Z_VCPKG_TOOLS_DIRS_BIN}) foreach(Z_VCPKG_TOOLS_DIR IN LISTS Z_VCPKG_TOOLS_DIRS) list(APPEND CMAKE_PROGRAM_PATH "${Z_VCPKG_TOOLS_DIR}") endforeach() - unset(Z_VCPKG_TOOLS_DIRS) unset(Z_VCPKG_TOOLS_DIR) + unset(Z_VCPKG_TOOLS_DIRS) + unset(Z_VCPKG_TOOLS_FILES) + unset(Z_VCPKG_TOOLS_DIRS_BIN) + unset(Z_VCPKG_TOOLS_FILES_BIN) + unset(Z_VCPKG_TOOLS_DIRS_TO_REMOVE) unset(tools_base_path) endif()