зеркало из https://github.com/microsoft/vcpkg.git
[vcpkg.cmake] fix X_VCPKG_APPLOCAL_DEPS_INSTALL (#18607)
* [vcpkg.cmake] fix X_VCPKG_APPLOCAL_DEPS_INSTALL * Billy CR
This commit is contained in:
Родитель
3335dadc75
Коммит
b361c2eefa
|
@ -609,29 +609,48 @@ endfunction()
|
||||||
#
|
#
|
||||||
# Note that this function requires CMake 3.14 for policy CMP0087
|
# Note that this function requires CMake 3.14 for policy CMP0087
|
||||||
function(x_vcpkg_install_local_dependencies)
|
function(x_vcpkg_install_local_dependencies)
|
||||||
if(Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp")
|
if(CMAKE_VERSION VERSION_LESS "3.14")
|
||||||
cmake_parse_arguments(PARSE_ARGV 0 __VCPKG_APPINSTALL "" "DESTINATION;COMPONENT" "TARGETS")
|
message(FATAL_ERROR "x_vcpkg_install_local_dependencies and X_VCPKG_APPLOCAL_DEPS_INSTALL require at least CMake 3.14
|
||||||
|
(current version: ${CMAKE_VERSION})"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
""
|
||||||
|
"DESTINATION;COMPONENT"
|
||||||
|
"TARGETS"
|
||||||
|
)
|
||||||
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||||
|
endif()
|
||||||
|
if(NOT DEFINED arg_DESTINATION)
|
||||||
|
message(FATAL_ERROR "DESTINATION must be specified")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "^(windows|uwp)$")
|
||||||
|
# Install CODE|SCRIPT allow the use of generator expressions
|
||||||
|
cmake_policy(SET CMP0087 NEW)
|
||||||
|
|
||||||
z_vcpkg_set_powershell_path()
|
z_vcpkg_set_powershell_path()
|
||||||
if(NOT IS_ABSOLUTE "${__VCPKG_APPINSTALL_DESTINATION}")
|
if(NOT IS_ABSOLUTE "${arg_DESTINATION}")
|
||||||
set(__VCPKG_APPINSTALL_DESTINATION "\${CMAKE_INSTALL_PREFIX}/${__VCPKG_APPINSTALL_DESTINATION}")
|
set(arg_DESTINATION "\${CMAKE_INSTALL_PREFIX}/${arg_DESTINATION}")
|
||||||
endif()
|
endif()
|
||||||
if(__VCPKG_APPINSTALL_COMPONENT)
|
|
||||||
set(__VCPKG_APPINSTALL_COMPONENT COMPONENT ${__VCPKG_APPINSTALL_COMPONENT})
|
set(component_param "")
|
||||||
|
if(DEFINED arg_COMPONENT)
|
||||||
|
set(component_param COMPONENT "${arg_COMPONENT}")
|
||||||
endif()
|
endif()
|
||||||
foreach(TARGET IN LISTS __VCPKG_APPINSTALL_TARGETS)
|
|
||||||
get_target_property(TARGETTYPE "${TARGET}" TYPE)
|
foreach(target IN LISTS arg_TARGETS)
|
||||||
if(NOT TARGETTYPE STREQUAL "INTERFACE_LIBRARY")
|
get_target_property(target_type "${target}" TYPE)
|
||||||
# Install CODE|SCRIPT allow the use of generator expressions
|
if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
if(POLICY CMP0087)
|
install(CODE "message(\"-- Installing app dependencies for ${target}...\")
|
||||||
cmake_policy(SET CMP0087 NEW)
|
|
||||||
endif()
|
|
||||||
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\"
|
execute_process(COMMAND \"${Z_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||||
-targetBinary \"${__VCPKG_APPINSTALL_DESTINATION}/$<TARGET_FILE_NAME:${TARGET}>\"
|
-targetBinary \"${arg_DESTINATION}/$<TARGET_FILE_NAME:${target}>\"
|
||||||
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
|
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
|
||||||
-OutVariable out)"
|
-OutVariable out)"
|
||||||
${__VCPKG_APPINSTALL_COMPONENT}
|
${component_param}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
@ -644,41 +663,43 @@ if(X_VCPKG_APPLOCAL_DEPS_INSTALL)
|
||||||
|
|
||||||
if(ARGV0 STREQUAL "TARGETS")
|
if(ARGV0 STREQUAL "TARGETS")
|
||||||
# Will contain the list of targets
|
# Will contain the list of targets
|
||||||
set(PARSED_TARGETS "")
|
set(parsed_targets "")
|
||||||
|
|
||||||
# Destination - [RUNTIME] DESTINATION argument overrides this
|
# Destination - [RUNTIME] DESTINATION argument overrides this
|
||||||
set(DESTINATION "bin")
|
set(destination "bin")
|
||||||
|
|
||||||
|
set(component_param "")
|
||||||
|
|
||||||
# Parse arguments given to the install function to find targets and (runtime) destination
|
# Parse arguments given to the install function to find targets and (runtime) destination
|
||||||
set(MODIFIER "") # Modifier for the command in the argument
|
set(modifier "") # Modifier for the command in the argument
|
||||||
set(LAST_COMMAND "") # Last command we found to process
|
set(last_command "") # Last command we found to process
|
||||||
foreach(ARG IN LISTS ARGS)
|
foreach(arg IN LISTS ARGS)
|
||||||
if(ARG MATCHES "ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE|INCLUDES")
|
if(arg MATCHES "^(ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE|INCLUDES)$")
|
||||||
set(MODIFIER "${ARG}")
|
set(modifier "${arg}")
|
||||||
continue()
|
continue()
|
||||||
endif()
|
endif()
|
||||||
if(ARG MATCHES "TARGETS|DESTINATION|PERMISSIONS|CONFIGURATIONS|COMPONENT|NAMELINK_COMPONENT|OPTIONAL|EXCLUDE_FROM_ALL|NAMELINK_ONLY|NAMELINK_SKIP|EXPORT")
|
if(arg MATCHES "^(TARGETS|DESTINATION|PERMISSIONS|CONFIGURATIONS|COMPONENT|NAMELINK_COMPONENT|OPTIONAL|EXCLUDE_FROM_ALL|NAMELINK_ONLY|NAMELINK_SKIP|EXPORT)$")
|
||||||
set(LAST_COMMAND "${ARG}")
|
set(last_command "${arg}")
|
||||||
continue()
|
continue()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LAST_COMMAND STREQUAL "TARGETS")
|
if(last_command STREQUAL "TARGETS")
|
||||||
list(APPEND PARSED_TARGETS "${ARG}")
|
list(APPEND parsed_targets "${arg}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LAST_COMMAND STREQUAL "DESTINATION" AND (MODIFIER STREQUAL "" OR MODIFIER STREQUAL "RUNTIME"))
|
if(last_command STREQUAL "DESTINATION" AND (MODIFIER STREQUAL "" OR MODIFIER STREQUAL "RUNTIME"))
|
||||||
set(DESTINATION "${ARG}")
|
set(destination "${arg}")
|
||||||
endif()
|
endif()
|
||||||
if(LAST_COMMAND STREQUAL "COMPONENT")
|
if(last_command STREQUAL "COMPONENT")
|
||||||
set(COMPONENT "${ARG}")
|
set(component_param "COMPONENT" "${arg}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# COMPONENT is optional only set it when it's been set by the install rule
|
x_vcpkg_install_local_dependencies(
|
||||||
if(COMPONENT)
|
TARGETS ${parsed_targets}
|
||||||
set(COMPONENT "COMPONENT" ${COMPONENT})
|
DESTINATION "${destination}"
|
||||||
endif()
|
${component_param}
|
||||||
x_vcpkg_install_local_dependencies(TARGETS "${PARSED_TARGETS}" DESTINATION "${DESTINATION}" ${COMPONENT})
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
endif()
|
endif()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче