|
49 | 49 | Invoke-WebRequest -URI $URLMingw -OutFile $PathMingw7Zip |
50 | 50 | & $Path7zipApp $UnzipMingw |
51 | 51 | Remove-Item -ErrorAction Ignore $PathMingw7Zip |
| 52 | + |
| 53 | + $URLCMake = "https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-windows-x86_64.zip" |
| 54 | + $PathCMakeZip = "cmake.zip" |
| 55 | + $PathCMake = "cmake_installation" |
| 56 | + Remove-Item -ErrorAction Ignore $PathCMakeZip |
| 57 | + Remove-Item -ErrorAction Ignore -Recurse $PathCMake |
| 58 | + Invoke-WebRequest -URI $URLCMake -OutFile $PathCMakeZip |
| 59 | + Expand-Archive -Path $PathCMakeZip -DestinationPath "." |
| 60 | + # Rename the extracted folder to 'cmake' |
| 61 | + $ExtractedFolder = Get-ChildItem -Directory -Name "cmake-*" | Select-Object -First 1 |
| 62 | + if ($ExtractedFolder) { |
| 63 | + Rename-Item -Path $ExtractedFolder -NewName $PathCMake |
| 64 | + } |
| 65 | + Remove-Item -ErrorAction Ignore $PathCMakeZip |
| 66 | + |
| 67 | + # Get the absolute path to CMake |
| 68 | + $CMakeBinPath = Join-Path (Get-Location) "cmake_installation\bin" |
| 69 | + $CMakeExe = Join-Path $CMakeBinPath "cmake.exe" |
| 70 | + |
| 71 | + # Get the absolute path to CMake |
| 72 | + $CMakeBinPath = Join-Path (Get-Location) "cmake_installation\bin" |
| 73 | + $CMakeExe = Join-Path $CMakeBinPath "cmake.exe" |
| 74 | + |
| 75 | + Write-Host "CMake and MinGW installed" |
| 76 | + Write-Host "CMake path: $CMakeBinPath" |
| 77 | + $MingwBinPath = Join-Path (Get-Location) "mingw64\bin" |
| 78 | + Write-Host "MinGW path: $MingwBinPath" |
| 79 | +} |
| 80 | + |
| 81 | +# Verify CMake installation using full path |
| 82 | +if (Test-Path $CMakeExe) { |
| 83 | + Write-Host "CMake installation verified successfully" |
| 84 | + Write-Host "CMake executable location: $CMakeExe" |
| 85 | + try { |
| 86 | + & $CMakeExe --version |
| 87 | + Write-Host "" |
| 88 | + Write-Host "To use CMake in your current session, add it to PATH with:" |
| 89 | + Write-Host "`$env:PATH = `"$CMakeBinPath;`$env:PATH`"" |
| 90 | + Write-Host "" |
| 91 | + Write-Host "Or use the full path: $CMakeExe" |
| 92 | + } |
| 93 | + catch { |
| 94 | + Write-Warning "CMake executable found but failed to run: $_" |
| 95 | + } |
| 96 | +} else { |
| 97 | + Write-Warning "CMake installation failed - executable not found at $CMakeExe" |
| 98 | + Write-Host "Checking what was extracted..." |
| 99 | + if (Test-Path $PathCMake) { |
| 100 | + Get-ChildItem -Path $PathCMake -Recurse -Name "cmake.exe" |
| 101 | + } |
52 | 102 | } |
| 103 | + |
| 104 | +# Optionally, update PATH for current session |
| 105 | +Write-Host "" |
| 106 | +Write-Host "Updating PATH for current PowerShell session..." |
| 107 | +$env:PATH = "$CMakeBinPath;$env:PATH" |
| 108 | +$env:PATH = "C:\Users\circleci\project\cmake_installation\bin;$env:PATH" |
| 109 | +Write-Host "CMake should now be available as 'cmake' command in this session" |
| 110 | + |
| 111 | +# Test if cmake is now available |
| 112 | +try { |
| 113 | + cmake --version |
| 114 | + Write-Host "SUCCESS: CMake is now available in PATH" |
| 115 | +} |
| 116 | +catch { |
| 117 | + Write-Warning "CMake still not available in PATH. Use full path: $CMakeExe" |
| 118 | +} |
| 119 | + |
0 commit comments