Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/windows-setup-agent/Icinga2SetupAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Icinga</RootNamespace>
<AssemblyName>Icinga2SetupAgent</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
Expand Down
12 changes: 9 additions & 3 deletions tools/win32/configure-dev.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Set-PsDebug -Trace 1

# Specify default targets for VS 2022 for developers.
. "$PSScriptRoot\find-vs.ps1"

# Specify default targets for developers.

if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
$env:ICINGA2_BUILDPATH = '.\debug'
Expand All @@ -22,7 +24,10 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
$env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
}
if (-not (Test-Path env:CMAKE_GENERATOR)) {
$env:CMAKE_GENERATOR = 'Visual Studio 17 2022'
$env:CMAKE_GENERATOR = Get-VSCMakeGenerator
}
if (-not (Test-Path env:CMAKE_GENERATOR_TOOLSET)) {
$env:CMAKE_GENERATOR_TOOLSET = 'v143'
}
if (-not (Test-Path env:CMAKE_GENERATOR_PLATFORM)) {
$env:CMAKE_GENERATOR_PLATFORM = 'x64'
Expand Down Expand Up @@ -57,7 +62,8 @@ if (Test-Path CMakeCache.txt) {

& cmake.exe "$sourcePath" `
-DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" `
-G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" -DCPACK_GENERATOR=WIX `
-G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" `
-T "$env:CMAKE_GENERATOR_TOOLSET" -DCPACK_GENERATOR=WIX `
-DCMAKE_INSTALL_PREFIX="$env:ICINGA2_INSTALLPATH" `
-DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" `
-DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" `
Expand Down
10 changes: 8 additions & 2 deletions tools/win32/configure.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Set-PsDebug -Trace 1

. "$PSScriptRoot\find-vs.ps1"

if (-not (Test-Path env:ICINGA2_BUILDPATH)) {
$env:ICINGA2_BUILDPATH = '.\build'
}
Expand All @@ -17,7 +19,10 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
$env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
}
if (-not (Test-Path env:CMAKE_GENERATOR)) {
$env:CMAKE_GENERATOR = 'Visual Studio 17 2022'
$env:CMAKE_GENERATOR = Get-VSCMakeGenerator
}
if (-not (Test-Path env:CMAKE_GENERATOR_TOOLSET)) {
$env:CMAKE_GENERATOR_TOOLSET = 'v143'
}
if (-not (Test-Path env:BITS)) {
$env:BITS = 64
Expand Down Expand Up @@ -61,7 +66,8 @@ if (Test-Path CMakeCache.txt) {

& cmake.exe "$sourcePath" `
-DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" `
-G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" -DCPACK_GENERATOR=WIX `
-G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" `
-T "$env:CMAKE_GENERATOR_TOOLSET" -DCPACK_GENERATOR=WIX `
-DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" `
-DBOOST_LIBRARYDIR="$env:BOOST_LIBRARYDIR" `
-DBOOST_INCLUDEDIR="$env:BOOST_ROOT" `
Expand Down
50 changes: 50 additions & 0 deletions tools/win32/find-vs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Query a single `vswhere` property for the selected VS install. The auto-detection can be
# overriden by setting the VS_INSTALL_PATH environment variable.
# By default, the latest install that has the C++ (x86/x64) toolset will be selected.
# If `vswhere` itself cannot be found or if it did not successfully return the requested
# property an error will be thrown.
function Get-VSProperty($property) {
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path $vswhere)) {
throw "Could not find vswhere.exe at: ${vswhere}"
}

if (Test-Path env:VS_INSTALL_PATH) {
$selector = @('-path', $env:VS_INSTALL_PATH)
} else {
$selector = @('-latest', '-products', '*',
'-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64')
}

$value = & $vswhere @selector -property $property
if ($LastExitCode -ne 0 -or [string]::IsNullOrEmpty($value)) {
throw "vswhere could not determine '${property}' for the selected Visual Studio installation"
}

return $value
}

# Root directory of the VS installation for locating the vcvars*.bat file.
function Get-VSInstallPath {
return Get-VSProperty 'installationPath'
}

# CMake can auto-detect the latest installed VS version, but that doesn't have to align with the
# version we have selected above, for example when using the VS_INSTALL_PATH override.
# Therefore it is generated from the same `vswhere` result that is used to detect the VS path.
# An error is thrown if the VS version we have selected is not supported by CMake.
function Get-VSCMakeGenerator {
$major = (Get-VSProperty 'installationVersion').Split('.')[0]

# Get the supported VS versions from CMake and check match it against the one we have.
$generator = & cmake.exe --help |
Select-String -Pattern "(Visual Studio $major\b[^=]*)=" |
ForEach-Object { $_.Matches.Groups[1].Value.Trim() } |
Select-Object -First 1

if (-not $generator) {
throw "Installed CMake has no 'Visual Studio $major' generator (CMake too old for this VS?); set CMAKE_GENERATOR to override"
}

return $generator
}
28 changes: 5 additions & 23 deletions tools/win32/load-vsenv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Set-PsDebug -Trace 1

. "$PSScriptRoot\find-vs.ps1"

$SOURCE = Get-Location

if (Test-Path env:ICINGA2_BUILDPATH) {
Expand All @@ -15,35 +17,15 @@ if (-not (Test-Path $BUILD)) {
mkdir $BUILD | Out-Null
}

if (Test-Path env:VS_INSTALL_PATH) {
$VSBASE = $env:VS_INSTALL_PATH
} else {
$VSBASE = "C:\Program Files\Microsoft Visual Studio\2022"
}

if (Test-Path env:BITS) {
$bits = $env:BITS
} else {
$bits = 64
}

# Execute vcvars in cmd and store env
$vcvars_locations = @(
"${VSBASE}\BuildTools\VC\Auxiliary\Build\vcvars${bits}.bat"
"${VSBASE}\Community\VC\Auxiliary\Build\vcvars${bits}.bat"
"${VSBASE}\Enterprise\VC\Auxiliary\Build\vcvars${bits}.bat"
)

$vcvars = $null
foreach ($file in $vcvars_locations) {
if (Test-Path $file) {
$vcvars = $file
break
}
}

if ($vcvars -eq $null) {
throw "Could not get Build environment script at locations: ${vcvars_locations}"
$vcvars = "$(Get-VSInstallPath)\VC\Auxiliary\Build\vcvars${bits}.bat"
if (-not (Test-Path $vcvars)) {
throw "Could not get Build environment script at location: ${vcvars}"
}

cmd.exe /c "call `"${vcvars}`" && set > `"${BUILD}\vcvars.txt`""
Expand Down
Loading