[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
This commit is contained in:
Alexander Neumann 2022-03-30 02:12:24 +02:00 committed by GitHub
parent d2fd9975f6
commit 16ebf7b9b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()