[Build] Make powershell optional on non-Windows (#1248)

Fixes: #1247
This commit is contained in:
Fabrice de Gans 2024-03-15 11:32:24 -07:00 committed by GitHub
parent f96e42fe04
commit 1d051d0e6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 3 deletions

View File

@ -28,7 +28,7 @@ if(WIN32)
HINTS "/Windows/System32/WindowsPowerShell/v1.0"
REQUIRED)
else()
find_program(POWERSHELL pwsh REQUIRED)
find_program(POWERSHELL pwsh)
endif()
include(Set-Toolchain-vcpkg)

View File

@ -184,8 +184,10 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("CHANGELOG.md.work") -replace "`r`n", "`n"

View File

@ -320,6 +320,9 @@ function(vcpkg_remove_optional_deps vcpkg_exe)
endfunction()
function(vcpkg_set_toolchain)
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to use vcpkg binaries.")
endif()
if(NOT DEFINED ENV{VCPKG_ROOT})
get_filename_component(preferred_root ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE)

View File

@ -75,8 +75,10 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("appcast.xml.work") -replace "`r`n", "`n"

View File

@ -158,6 +158,9 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(ENV{PATH} "${dbg_prefix}/bin;${common_prefix}/bin;$ENV{PATH}")
if(NOT ZIP_PROGRAM AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/zip.exe)
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required for extraction.")
endif()
# get zip binary for wxrc
file(DOWNLOAD "https://www.willus.com/archive/zip64/infozip_binaries_win32.zip" ${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip)
# unzip it