diff options
| author | Billy O'Neal <bion@microsoft.com> | 2020-11-01 17:12:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-01 17:12:49 -0800 |
| commit | b7056e9f1f34f18b6648b1f1d9c4e9d31f04e91c (patch) | |
| tree | 75e127191e18904a09c9b5213521c75761d801df /scripts/buildsystems | |
| parent | e9ff3cd5a04cd0e8122ff56e9873985ff71aa3ca (diff) | |
| download | vcpkg-b7056e9f1f34f18b6648b1f1d9c4e9d31f04e91c.tar.gz vcpkg-b7056e9f1f34f18b6648b1f1d9c4e9d31f04e91c.zip | |
[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
Diffstat (limited to 'scripts/buildsystems')
| -rw-r--r-- | scripts/buildsystems/vcpkg.cmake | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index dab5b73a6..2a8942297 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -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)") |
