From 5373483963e6509e34c2e38c16291ce55650c68d Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 25 May 2022 10:29:57 -0700 Subject: [PATCH] Tools: Add a CMakeExecutable parameter to win-setup.ps1. 52054046c1 switched archive extraction from 7Zip to CMake. This removed a dependency on 7Zip, but assumed that CMake was in our PATH. Add a CMakeExecutable to win-setup.ps1 and use it in CMakeLists.txt to pass the value of CMAKE_COMMAND. --- CMakeLists.txt | 3 ++- tools/win-setup.ps1 | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c131ab63d1..96611aff64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,12 +181,13 @@ and CPU target ${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE}" # Download third-party libraries file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup) file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir) + file (TO_NATIVE_PATH ${CMAKE_COMMAND} _win_cmake_command) # Is it possible to have a one-time, non-cached option in CMake? If # so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to # win-setup.ps1. execute_process( - COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} + COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} -CMakeExecutable "\"${_win_cmake_command}\"" RESULT_VARIABLE _win_setup_failed ERROR_VARIABLE _win_setup_error_output ) diff --git a/tools/win-setup.ps1 b/tools/win-setup.ps1 index 2d63e9f3c7..8b1da23f0e 100644 --- a/tools/win-setup.ps1 +++ b/tools/win-setup.ps1 @@ -29,9 +29,13 @@ contain the pattern "wireshark-*-libs". .PARAMETER Platform Target platform. Must be "win64". +.PARAMETER CMakeExecutable +Specifies the path to the CMake executable, which is used to extract archives. + .INPUTS -Destination Destination directory. -Platform Target platform. +-CMakeExecutable Path to CMake. .OUTPUTS A set of libraries required to compile Wireshark on Windows, along with @@ -51,7 +55,12 @@ Param( [Parameter(Mandatory=$true, Position=1)] [ValidateSet("win64")] [String] - $Platform + $Platform, + + [Parameter(Mandatory=$false, Position=3)] + [ValidateScript({$_ | Test-Path -Type leaf })] + [String] + $CMakeExecutable = "CMake" ) # Variables @@ -220,7 +229,7 @@ function DownloadArchive($fileName, $fileHash, $subDir) { $activity = "Extracting into $($archiveDir)" Write-Progress -Activity "$activity" -Status "Extracting $archiveFile using CMake ..." Push-Location "$archiveDir" - & cmake -E tar xf "$archiveFile" 2>&1 | Set-Variable -Name CMakeOut + & "$CMakeExecutable" -E tar xf "$archiveFile" 2>&1 | Set-Variable -Name CMakeOut $cmStatus = $LASTEXITCODE Pop-Location Write-Progress -Activity "$activity" -Status "Done" -Completed