mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 11:21:12 +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)
|
if(VCPKG_TARGET_TRIPLET)
|
||||||
# This is required since a user might do: 'set(VCPKG_TARGET_TRIPLET somevalue)' [no CACHE] before the first project() call
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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!
|
# 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)
|
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$")
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
|
||||||
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
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)
|
list(APPEND CMAKE_PROGRAM_PATH ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools)
|
||||||
file(GLOB _VCPKG_TOOLS_DIRS ${_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})
|
foreach(_VCPKG_TOOLS_DIR IN LISTS _VCPKG_TOOLS_DIRS)
|
||||||
if(IS_DIRECTORY ${_VCPKG_TOOLS_DIR})
|
if(IS_DIRECTORY "${_VCPKG_TOOLS_DIR}")
|
||||||
list(APPEND CMAKE_PROGRAM_PATH ${_VCPKG_TOOLS_DIR})
|
list(APPEND CMAKE_PROGRAM_PATH "${_VCPKG_TOOLS_DIR}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT _CMAKE_IN_TRY_COMPILE)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(feature ${VCPKG_MANIFEST_FEATURES})
|
foreach(feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||||
list(APPEND _VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-feature=${feature}")
|
list(APPEND _VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-feature=${feature}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@ -399,12 +399,17 @@ function(_vcpkg_set_powershell_path)
|
|||||||
# Attempt to use pwsh if it is present; otherwise use powershell
|
# Attempt to use pwsh if it is present; otherwise use powershell
|
||||||
if (NOT DEFINED _VCPKG_POWERSHELL_PATH)
|
if (NOT DEFINED _VCPKG_POWERSHELL_PATH)
|
||||||
find_program(_VCPKG_PWSH_PATH pwsh)
|
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")
|
message(DEBUG "vcpkg: Could not find PowerShell Core; falling back to PowerShell")
|
||||||
find_program(_VCPKG_BUILTIN_POWERSHELL_PATH powershell REQUIRED)
|
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.")
|
if (_VCPKG_BUILTIN_POWERSHELL_PATH)
|
||||||
else()
|
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_BUILTIN_POWERSHELL_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use.")
|
||||||
set(_VCPKG_POWERSHELL_PATH "${_VCPKG_PWSH_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()
|
||||||
endif() # _VCPKG_POWERSHELL_PATH
|
endif() # _VCPKG_POWERSHELL_PATH
|
||||||
endfunction()
|
endfunction()
|
||||||
@ -471,13 +476,11 @@ endfunction()
|
|||||||
# DESTINATION - the runtime directory for those targets (usually `bin`)
|
# DESTINATION - the runtime directory for those targets (usually `bin`)
|
||||||
function(x_vcpkg_install_local_dependencies)
|
function(x_vcpkg_install_local_dependencies)
|
||||||
if(_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp")
|
if(_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp")
|
||||||
# Parse command line
|
cmake_parse_arguments(PARSE_ARGV __VCPKG_APPINSTALL "" "DESTINATION" "TARGETS")
|
||||||
cmake_parse_arguments(__VCPKG_APPINSTALL "" "DESTINATION" "TARGETS" ${ARGN})
|
_vcpkg_set_powershell_path()
|
||||||
|
foreach(TARGET IN LISTS __VCPKG_APPINSTALL_TARGETS)
|
||||||
foreach(TARGET ${__VCPKG_APPINSTALL_TARGETS})
|
|
||||||
install(CODE "message(\"-- Installing app dependencies for ${TARGET}...\")
|
install(CODE "message(\"-- Installing app dependencies for ${TARGET}...\")
|
||||||
execute_process(COMMAND
|
execute_process(COMMAND \"${_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
||||||
powershell -noprofile -executionpolicy Bypass -file \"${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
|
|
||||||
-targetBinary \"\${CMAKE_INSTALL_PREFIX}/${__VCPKG_APPINSTALL_DESTINATION}/$<TARGET_FILE_NAME:${TARGET}>\"
|
-targetBinary \"\${CMAKE_INSTALL_PREFIX}/${__VCPKG_APPINSTALL_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)")
|
||||||
|
@ -18,22 +18,22 @@
|
|||||||
## * [fltk](https://github.com/Microsoft/vcpkg/blob/master/ports/fltk/portfile.cmake)
|
## * [fltk](https://github.com/Microsoft/vcpkg/blob/master/ports/fltk/portfile.cmake)
|
||||||
function(vcpkg_copy_tool_dependencies TOOL_DIR)
|
function(vcpkg_copy_tool_dependencies TOOL_DIR)
|
||||||
find_program(PWSH_EXE pwsh)
|
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.")
|
message(FATAL_ERROR "Could not find PowerShell Core; please open an issue to report this.")
|
||||||
endif()
|
endif()
|
||||||
macro(search_for_dependencies PATH_TO_SEARCH)
|
macro(search_for_dependencies PATH_TO_SEARCH)
|
||||||
file(GLOB TOOLS ${TOOL_DIR}/*.exe ${TOOL_DIR}/*.dll)
|
file(GLOB TOOLS "${TOOL_DIR}/*.exe" "${TOOL_DIR}/*.dll")
|
||||||
foreach(TOOL ${TOOLS})
|
foreach(TOOL IN LISTS TOOLS)
|
||||||
vcpkg_execute_required_process(
|
vcpkg_execute_required_process(
|
||||||
COMMAND "${PWSH_EXE}" -noprofile -executionpolicy Bypass -nologo
|
COMMAND "${PWSH_EXE}" -noprofile -executionpolicy Bypass -nologo
|
||||||
-file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
|
-file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1"
|
||||||
-targetBinary ${TOOL}
|
-targetBinary "${TOOL}"
|
||||||
-installedDir ${PATH_TO_SEARCH}
|
-installedDir "${PATH_TO_SEARCH}"
|
||||||
WORKING_DIRECTORY ${VCPKG_ROOT_DIR}
|
WORKING_DIRECTORY "${VCPKG_ROOT_DIR}"
|
||||||
LOGNAME copy-tool-dependencies
|
LOGNAME copy-tool-dependencies
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
search_for_dependencies(${CURRENT_PACKAGES_DIR}/bin)
|
search_for_dependencies("${CURRENT_PACKAGES_DIR}/bin")
|
||||||
search_for_dependencies(${CURRENT_INSTALLED_DIR}/bin)
|
search_for_dependencies("${CURRENT_INSTALLED_DIR}/bin")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user