mirror of https://github.com/microsoft/vcpkg.git
Use `z-applocal` instead of `applocal.ps1` by default. (#52315)
This commit is contained in:
parent
2a934a0a7f
commit
b8ab03c3c5
|
|
@ -48,8 +48,8 @@
|
|||
</BoolProperty.DataSource>
|
||||
</BoolProperty>
|
||||
|
||||
<BoolProperty Name="VcpkgXUseBuiltInApplocalDeps" DisplayName="Use built-in app-local deployment" Category="General" Default="false"
|
||||
Description="(experimental) When copying DLL dependencies, use built-in-to-vcpkg implementation rather than PowerShell script.">
|
||||
<BoolProperty Name="VcpkgXUseBuiltInApplocalDeps" DisplayName="Use built-in app-local deployment" Category="General" Default="true"
|
||||
Description="When copying DLL dependencies, use built-in-vcpkg implementation rather than PowerShell script.">
|
||||
<BoolProperty.DataSource>
|
||||
<DataSource Persistence="ProjectFile" Label="Vcpkg" HasConfigurationCondition="false" />
|
||||
</BoolProperty.DataSource>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
Tried to add /lib as a parameter to the linker call but was unable to find a way to pass it as the first parameter. -->
|
||||
<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true' OR '$(PlatformToolset.ToLower())' == 'clangcl'">false</VcpkgAutoLink>
|
||||
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
|
||||
<VcpkgXUseBuiltInApplocalDeps Condition="'$(VcpkgXUseBuiltInApplocalDeps)' == ''">false</VcpkgXUseBuiltInApplocalDeps>
|
||||
<VcpkgXUseBuiltInApplocalDeps Condition="'$(VcpkgXUseBuiltInApplocalDeps)' == ''">true</VcpkgXUseBuiltInApplocalDeps>
|
||||
|
||||
<!-- Classic Mode: The following line is edited by the mint standalone bundle script to be false for standlone copies -->
|
||||
<VcpkgEnableClassic Condition="'$(VcpkgEnableClassic)' == ''">true</VcpkgEnableClassic>
|
||||
|
|
|
|||
|
|
@ -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(VCPKG_USE_LEGACY_APPLOCAL "Use applocal.ps1 instead of vcpkg z-applocal." OFF)
|
||||
|
||||
# requires CMake 3.14
|
||||
option(X_VCPKG_APPLOCAL_DEPS_INSTALL "(experimental) Automatically copy dependencies into the install target directory for executables. Requires CMake 3.14." OFF)
|
||||
|
|
@ -620,19 +621,29 @@ function(add_executable)
|
|||
if(IMPORTED_IDX EQUAL "-1" AND ALIAS_IDX EQUAL "-1")
|
||||
if(VCPKG_APPLOCAL_DEPS)
|
||||
if(Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox")
|
||||
z_vcpkg_set_powershell_path()
|
||||
set(EXTRA_OPTIONS "")
|
||||
if(X_VCPKG_APPLOCAL_DEPS_SERIALIZED)
|
||||
set(EXTRA_OPTIONS USES_TERMINAL)
|
||||
endif()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_POWERSHELL_PATH}" -noprofile -executionpolicy Bypass -file "${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1"
|
||||
-targetBinary "$<TARGET_FILE:${target_name}>"
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-OutVariable out
|
||||
VERBATIM
|
||||
${EXTRA_OPTIONS}
|
||||
)
|
||||
if(VCPKG_USE_LEGACY_APPLOCAL)
|
||||
z_vcpkg_set_powershell_path()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_POWERSHELL_PATH}" -noprofile -executionpolicy Bypass -file "${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1"
|
||||
-targetBinary "$<TARGET_FILE:${target_name}>"
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-OutVariable out
|
||||
VERBATIM
|
||||
${EXTRA_OPTIONS}
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_EXECUTABLE}" z-applocal
|
||||
"--target-binary=$<TARGET_FILE:${target_name}>"
|
||||
"--installed-bin-dir=${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
VERBATIM
|
||||
${EXTRA_OPTIONS}
|
||||
)
|
||||
endif()
|
||||
elseif(Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "osx")
|
||||
if(NOT MACOSX_BUNDLE_IDX EQUAL "-1")
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
|
|
@ -661,14 +672,23 @@ function(add_library)
|
|||
if(IMPORTED_IDX EQUAL "-1" AND INTERFACE_IDX EQUAL "-1" AND ALIAS_IDX EQUAL "-1")
|
||||
get_target_property(IS_LIBRARY_SHARED "${target_name}" TYPE)
|
||||
if(VCPKG_APPLOCAL_DEPS AND Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox" AND (IS_LIBRARY_SHARED STREQUAL "SHARED_LIBRARY" OR IS_LIBRARY_SHARED STREQUAL "MODULE_LIBRARY"))
|
||||
z_vcpkg_set_powershell_path()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_POWERSHELL_PATH}" -noprofile -executionpolicy Bypass -file "${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1"
|
||||
-targetBinary "$<TARGET_FILE:${target_name}>"
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-OutVariable out
|
||||
if(VCPKG_USE_LEGACY_APPLOCAL)
|
||||
z_vcpkg_set_powershell_path()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_POWERSHELL_PATH}" -noprofile -executionpolicy Bypass -file "${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1"
|
||||
-targetBinary "$<TARGET_FILE:${target_name}>"
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-OutVariable out
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET "${target_name}" POST_BUILD
|
||||
COMMAND "${Z_VCPKG_EXECUTABLE}" z-applocal
|
||||
"--target-binary=$<TARGET_FILE:${target_name}>"
|
||||
"--installed-bin-dir=${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
VERBATIM
|
||||
)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
set_target_properties("${target_name}" PROPERTIES VS_USER_PROPS do_not_import_user.props)
|
||||
set_target_properties("${target_name}" PROPERTIES VS_GLOBAL_VcpkgEnabled false)
|
||||
|
|
@ -705,7 +725,6 @@ function(x_vcpkg_install_local_dependencies)
|
|||
# Install CODE|SCRIPT allow the use of generator expressions
|
||||
cmake_policy(SET CMP0087 NEW) # CMake 3.14
|
||||
|
||||
z_vcpkg_set_powershell_path()
|
||||
if(NOT IS_ABSOLUTE "${arg_DESTINATION}")
|
||||
set(arg_DESTINATION "\${CMAKE_INSTALL_PREFIX}/${arg_DESTINATION}")
|
||||
endif()
|
||||
|
|
@ -719,13 +738,23 @@ function(x_vcpkg_install_local_dependencies)
|
|||
foreach(target IN LISTS arg_TARGETS)
|
||||
get_target_property(target_type "${target}" TYPE)
|
||||
if(target_type IN_LIST allowed_target_types)
|
||||
install(CODE "message(\"-- Installing app dependencies for ${target}...\")
|
||||
execute_process(COMMAND \"${Z_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||
-targetBinary \"${arg_DESTINATION}/$<TARGET_FILE_NAME:${target}>\"
|
||||
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
|
||||
-OutVariable out)"
|
||||
${component_param}
|
||||
)
|
||||
if(VCPKG_USE_LEGACY_APPLOCAL)
|
||||
z_vcpkg_set_powershell_path()
|
||||
install(CODE "message(\"-- Installing app dependencies for ${target}...\")
|
||||
execute_process(COMMAND \"${Z_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||
-targetBinary \"${arg_DESTINATION}/$<TARGET_FILE_NAME:${target}>\"
|
||||
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
|
||||
-OutVariable out)"
|
||||
${component_param}
|
||||
)
|
||||
else()
|
||||
install(CODE "message(\"-- Installing app dependencies for ${target}...\")
|
||||
execute_process(COMMAND \"${Z_VCPKG_EXECUTABLE}\" z-applocal
|
||||
\"--target-binary=${arg_DESTINATION}/$<TARGET_FILE_NAME:${target}>\"
|
||||
\"--installed-bin-dir=${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\")"
|
||||
${component_param}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -6,15 +6,42 @@ function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search)
|
|||
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}
|
||||
)
|
||||
set(log_out "${CURRENT_BUILDTREES_DIR}/copy-tool-dependencies-${count}-out.log")
|
||||
set(log_err "${CURRENT_BUILDTREES_DIR}/copy-tool-dependencies-${count}-err.log")
|
||||
set(copied_files_log "${CURRENT_BUILDTREES_DIR}/copy-tool-dependencies-${count}-copied-files.log")
|
||||
file(REMOVE "${copied_files_log}")
|
||||
if(VCPKG_USE_LEGACY_APPLOCAL)
|
||||
vcpkg_execute_in_download_mode(
|
||||
COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -file "${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/applocal.ps1"
|
||||
-targetBinary "${tool}"
|
||||
-installedDir "${path_to_search}"
|
||||
-OutVariable out
|
||||
RESULT_VARIABLE error_code
|
||||
OUTPUT_VARIABLE out_var
|
||||
ERROR_VARIABLE err_var
|
||||
WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
|
||||
)
|
||||
else()
|
||||
vcpkg_execute_in_download_mode(
|
||||
COMMAND "$ENV{VCPKG_COMMAND}" z-applocal
|
||||
"--target-binary=${tool}"
|
||||
"--installed-bin-dir=${path_to_search}"
|
||||
"--copied-files-log=${copied_files_log}"
|
||||
RESULT_VARIABLE error_code
|
||||
OUTPUT_VARIABLE out_var
|
||||
ERROR_VARIABLE err_var
|
||||
WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
|
||||
)
|
||||
endif()
|
||||
file(WRITE "${log_out}" "${out_var}")
|
||||
if(EXISTS "${copied_files_log}")
|
||||
file(READ "${copied_files_log}" copied_files)
|
||||
file(APPEND "${log_out}" "${copied_files}")
|
||||
endif()
|
||||
file(WRITE "${log_err}" "${err_var}")
|
||||
if(NOT error_code STREQUAL "0" AND VCPKG_VERBOSE)
|
||||
message(STATUS "vcpkg failed to copy dependencies for ${tool}; see ${log_out} and ${log_err}.")
|
||||
endif()
|
||||
math(EXPR count "${count} + 1")
|
||||
endforeach()
|
||||
set(Z_VCPKG_COPY_TOOL_DEPENDENCIES_COUNT ${count} CACHE INTERNAL "")
|
||||
|
|
@ -26,8 +53,10 @@ function(vcpkg_copy_tool_dependencies tool_dir)
|
|||
endif()
|
||||
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
vcpkg_find_acquire_program(PWSH)
|
||||
set(Z_VCPKG_POWERSHELL_CORE "${PWSH}")
|
||||
if(VCPKG_USE_LEGACY_APPLOCAL)
|
||||
vcpkg_find_acquire_program(PWSH)
|
||||
set(Z_VCPKG_POWERSHELL_CORE "${PWSH}")
|
||||
endif()
|
||||
cmake_path(RELATIVE_PATH tool_dir
|
||||
BASE_DIRECTORY "${CURRENT_PACKAGES_DIR}"
|
||||
OUTPUT_VARIABLE relative_tool_dir
|
||||
|
|
|
|||
Loading…
Reference in New Issue