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.
This commit is contained in:
Gerald Combs 2022-05-25 10:29:57 -07:00 committed by A Wireshark GitLab Utility
parent e6a8318f18
commit 5373483963
2 changed files with 13 additions and 3 deletions

View File

@ -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
)

View File

@ -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