aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake')
-rw-r--r--vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake45
1 files changed, 45 insertions, 0 deletions
diff --git a/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake b/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
new file mode 100644
index 0000000..1928df6
--- /dev/null
+++ b/vcpkg/scripts/cmake/vcpkg_copy_tool_dependencies.cmake
@@ -0,0 +1,45 @@
+function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
+ if(DEFINED Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT)
+ set(count ${Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT})
+ else()
+ set(count 0)
+ endif()
+ file(GLOB tools "${tool_dir}/*.exe" "${tool_dir}/*.dll" "${tool_dir}/*.pyd")
+ foreach(tool IN LISTS tools)
+ vcpkg_execute_required_process(
+ COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -nologo
+ -file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
+ -targetBinary "${tool}"
+ -installedDir "${path_to_search}"
+ -verbose
+ WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
+ LOGNAME copy-tool-dependencies-${count}
+ )
+ math(EXPR count "${count} + 1")
+ endforeach()
+ set(Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT ${count} CACHE INTERNAL "")
+endfunction()
+
+function(vcpkg_copy_tool_dependencies tool_dir)
+ if(ARGC GREATER 1)
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${ARGN}")
+ endif()
+
+ if(VCPKG_TARGET_IS_WINDOWS)
+ find_program(Z_VCPKG_POWERSHELL_CORE pwsh)
+ if (NOT Z_VCPKG_POWERSHELL_CORE)
+ message(FATAL_ERROR "Could not find PowerShell Core; please open an issue to report this.")
+ endif()
+ cmake_path(RELATIVE_PATH tool_dir
+ BASE_DIRECTORY "${CURRENT_PACKAGES_DIR}"
+ OUTPUT_VARIABLE relative_tool_dir
+ )
+ if(relative_tool_dir MATCHES "^debug/|/debug/")
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/debug/bin")
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/debug/bin")
+ else()
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/bin")
+ z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/bin")
+ endif()
+ endif()
+endfunction()