mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[vcpkg] Fix incorrect determination of PowerShell not found (#14317)
* Fix incorrect determination of PowerShell not found because Bill doesn't know enough CMake :( Resolves #14283
This commit is contained in:
parent
e9ff3cd5a0
commit
b7056e9f1f
@ -106,11 +106,11 @@ endif()
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
# This is required since a user might do: 'set(VCPKG_TARGET_TRIPLET somevalue)' [no CACHE] before the first project() call
|
||||
# Latter within the toolchain file we do: 'set(VCPKG_TARGET_TRIPLET somevalue CACHE STRING "")' which
|
||||
# will otherwise override the user setting of VCPKG_TARGET_TRIPLET in the current scope of the toolchain since the CACHE value
|
||||
# did not exist previously. Since the value is newly created CMake will use the CACHE value within this scope since it is the more
|
||||
# will otherwise override the user setting of VCPKG_TARGET_TRIPLET in the current scope of the toolchain since the CACHE value
|
||||
# did not exist previously. Since the value is newly created CMake will use the CACHE value within this scope since it is the more
|
||||
# recently created value in directory scope. This 'strange' behaviour only happens on the very first configure call since subsequent
|
||||
# configure call will see the user value as the more recent value. The same logic must be applied to all cache values within this file!
|
||||
# The FORCE keyword is required to ALWAYS lift the user provided/previously set value into a CACHE value.
|
||||
# The FORCE keyword is required to ALWAYS lift the user provided/previously set value into a CACHE value.
|
||||
set(VCPKG_TARGET_TRIPLET ${VCPKG_TARGET_TRIPLET} CACHE STRING "Vcpkg target triplet (ex. x86-windows)" FORCE)
|
||||
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
|
||||
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
||||
@ -306,9 +306,9 @@ set(CMAKE_SYSTEM_IGNORE_PATH
|
||||
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools)
|
||||
file(GLOB _VCPKG_TOOLS_DIRS ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/*)
|
||||
foreach(_VCPKG_TOOLS_DIR ${_VCPKG_TOOLS_DIRS})
|
||||
if(IS_DIRECTORY ${_VCPKG_TOOLS_DIR})
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${_VCPKG_TOOLS_DIR})
|
||||
foreach(_VCPKG_TOOLS_DIR IN LISTS _VCPKG_TOOLS_DIRS)
|
||||
if(IS_DIRECTORY "${_VCPKG_TOOLS_DIR}")
|
||||
list(APPEND CMAKE_PROGRAM_PATH "${_VCPKG_TOOLS_DIR}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -361,7 +361,7 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT _CMAKE_IN_TRY_COMPILE)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(feature ${VCPKG_MANIFEST_FEATURES})
|
||||
foreach(feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||
list(APPEND _VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-feature=${feature}")
|
||||
endforeach()
|
||||
|
||||
@ -399,12 +399,17 @@ function(_vcpkg_set_powershell_path)
|
||||
# Attempt to use pwsh if it is present; otherwise use powershell
|
||||
if (NOT DEFINED _VCPKG_POWERSHELL_PATH)
|
||||
find_program(_VCPKG_PWSH_PATH pwsh)
|
||||
if (_VCPKG_PWSH_PATH-NOTFOUND)
|
||||
if (_VCPKG_PWSH_PATH)
|
||||
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_PWSH_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||
else()
|
||||
message(DEBUG "vcpkg: Could not find PowerShell Core; falling back to PowerShell")
|
||||
find_program(_VCPKG_BUILTIN_POWERSHELL_PATH powershell REQUIRED)
|
||||
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_BUILTIN_POWERSHELL_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||
else()
|
||||
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_PWSH_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||
if (_VCPKG_BUILTIN_POWERSHELL_PATH)
|
||||
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_BUILTIN_POWERSHELL_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||
else()
|
||||
message(WARNING "vcpkg: Could not find PowerShell; using static string 'powershell.exe'")
|
||||
set(_VCPKG_POWERSHELL_PATH "powershell.exe" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||
endif()
|
||||
endif()
|
||||
endif() # _VCPKG_POWERSHELL_PATH
|
||||
endfunction()
|
||||
@ -471,13 +476,11 @@ endfunction()
|
||||
# DESTINATION - the runtime directory for those targets (usually `bin`)
|
||||
function(x_vcpkg_install_local_dependencies)
|
||||
if(_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp")
|
||||
# Parse command line
|
||||
cmake_parse_arguments(__VCPKG_APPINSTALL "" "DESTINATION" "TARGETS" ${ARGN})
|
||||
|
||||
foreach(TARGET ${__VCPKG_APPINSTALL_TARGETS})
|
||||
cmake_parse_arguments(PARSE_ARGV __VCPKG_APPINSTALL "" "DESTINATION" "TARGETS")
|
||||
_vcpkg_set_powershell_path()
|
||||
foreach(TARGET IN LISTS __VCPKG_APPINSTALL_TARGETS)
|
||||
install(CODE "message(\"-- Installing app dependencies for ${TARGET}...\")
|
||||
execute_process(COMMAND
|
||||
powershell -noprofile -executionpolicy Bypass -file \"${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||
execute_process(COMMAND \"${_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||
-targetBinary \"\${CMAKE_INSTALL_PREFIX}/${__VCPKG_APPINSTALL_DESTINATION}/$<TARGET_FILE_NAME:${TARGET}>\"
|
||||
-installedDir \"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin\"
|
||||
-OutVariable out)")
|
||||
|
@ -18,22 +18,22 @@
|
||||
## * [fltk](https://github.com/Microsoft/vcpkg/blob/master/ports/fltk/portfile.cmake)
|
||||
function(vcpkg_copy_tool_dependencies TOOL_DIR)
|
||||
find_program(PWSH_EXE pwsh)
|
||||
if (PWSH_EXE-NOTFOUND)
|
||||
if (NOT PWSH_EXE)
|
||||
message(FATAL_ERROR "Could not find PowerShell Core; please open an issue to report this.")
|
||||
endif()
|
||||
macro(search_for_dependencies PATH_TO_SEARCH)
|
||||
file(GLOB TOOLS ${TOOL_DIR}/*.exe ${TOOL_DIR}/*.dll)
|
||||
foreach(TOOL ${TOOLS})
|
||||
file(GLOB TOOLS "${TOOL_DIR}/*.exe" "${TOOL_DIR}/*.dll")
|
||||
foreach(TOOL IN LISTS TOOLS)
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND "${PWSH_EXE}" -noprofile -executionpolicy Bypass -nologo
|
||||
-file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
|
||||
-targetBinary ${TOOL}
|
||||
-installedDir ${PATH_TO_SEARCH}
|
||||
WORKING_DIRECTORY ${VCPKG_ROOT_DIR}
|
||||
-targetBinary "${TOOL}"
|
||||
-installedDir "${PATH_TO_SEARCH}"
|
||||
WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
|
||||
LOGNAME copy-tool-dependencies
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
search_for_dependencies(${CURRENT_PACKAGES_DIR}/bin)
|
||||
search_for_dependencies(${CURRENT_INSTALLED_DIR}/bin)
|
||||
search_for_dependencies("${CURRENT_PACKAGES_DIR}/bin")
|
||||
search_for_dependencies("${CURRENT_INSTALLED_DIR}/bin")
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user