Skip to content

Commit e3800ae

Browse files
committed
Pin OpenCV dependency artifact to v142 toolset
1 parent 5198a44 commit e3800ae

6 files changed

Lines changed: 32 additions & 19 deletions

File tree

.github/workflows/opencv-dependency.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222

2323
env:
2424
OPENCV_VERSION: ${{ inputs.opencv_version || '4.3.0' }}
25+
OPENCV_TOOLSET: v142
2526

2627
steps:
2728
- name: Checkout
@@ -35,16 +36,17 @@ jobs:
3536
run: |
3637
.\build\Build-OpenCvDependency.ps1 `
3738
-Version $env:OPENCV_VERSION `
39+
-Toolset $env:OPENCV_TOOLSET `
3840
-Configurations Release,Debug `
3941
-Platform x64
4042
4143
- name: Package dependency
4244
id: package
4345
shell: pwsh
4446
run: |
45-
$packageName = "Q1View-opencv-$($env:OPENCV_VERSION)-msvc-x64-static-mt.zip"
47+
$packageName = "Q1View-opencv-$($env:OPENCV_VERSION)-msvc-$($env:OPENCV_TOOLSET)-x64-static-mt.zip"
4648
$hashFile = "$packageName.sha256.txt"
47-
$tagName = "deps-opencv-$($env:OPENCV_VERSION)-msvc-x64-static-mt"
49+
$tagName = "deps-opencv-$($env:OPENCV_VERSION)-msvc-$($env:OPENCV_TOOLSET)-x64-static-mt"
4850
$installRoot = ".deps\opencv-$($env:OPENCV_VERSION)-build\install"
4951
5052
if (-not (Test-Path "$installRoot\include\opencv2\core.hpp")) {
@@ -59,6 +61,7 @@ jobs:
5961
"# OpenCV dependency for Q1View",
6062
"",
6163
"- OpenCV: $env:OPENCV_VERSION",
64+
"- MSVC toolset: $env:OPENCV_TOOLSET",
6265
"- Package: $packageName",
6366
"- SHA256: $hash",
6467
"",
@@ -73,8 +76,7 @@ jobs:
7376
uses: softprops/action-gh-release@v2
7477
with:
7578
tag_name: ${{ steps.package.outputs.tag_name }}
76-
target_commitish: ${{ github.sha }}
77-
name: OpenCV ${{ env.OPENCV_VERSION }} dependency
79+
name: OpenCV ${{ env.OPENCV_VERSION }} dependency (${{ env.OPENCV_TOOLSET }})
7880
body_path: RELEASE_NOTES.md
7981
overwrite_files: true
8082
fail_on_unmatched_files: true

OpenCV4Debug.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
<PropertyGroup Label="UserMacros" />
55
<PropertyGroup>
66
<Q1ViewOpenCvVersion Condition="'$(Q1ViewOpenCvVersion)' == ''">4.3.0</Q1ViewOpenCvVersion>
7-
<Q1ViewOpenCvAssetName Condition="'$(Q1ViewOpenCvAssetName)' == ''">Q1View-opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt.zip</Q1ViewOpenCvAssetName>
8-
<Q1ViewOpenCvReleaseTag Condition="'$(Q1ViewOpenCvReleaseTag)' == ''">deps-opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt</Q1ViewOpenCvReleaseTag>
7+
<Q1ViewOpenCvToolset Condition="'$(Q1ViewOpenCvToolset)' == ''">v142</Q1ViewOpenCvToolset>
8+
<Q1ViewOpenCvAssetName Condition="'$(Q1ViewOpenCvAssetName)' == ''">Q1View-opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt.zip</Q1ViewOpenCvAssetName>
9+
<Q1ViewOpenCvReleaseTag Condition="'$(Q1ViewOpenCvReleaseTag)' == ''">deps-opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt</Q1ViewOpenCvReleaseTag>
910
<Q1ViewOpenCvArchiveUrl Condition="'$(Q1VIEW_OPENCV_URL)' != ''">$(Q1VIEW_OPENCV_URL)</Q1ViewOpenCvArchiveUrl>
1011
<Q1ViewOpenCvArchiveUrl Condition="'$(Q1ViewOpenCvArchiveUrl)' == ''">https://github.com/chammoru/Q1View/releases/download/$(Q1ViewOpenCvReleaseTag)/$(Q1ViewOpenCvAssetName)</Q1ViewOpenCvArchiveUrl>
1112
<Q1ViewOpenCvArchivePath Condition="'$(Q1VIEW_OPENCV_ARCHIVE)' != ''">$(Q1VIEW_OPENCV_ARCHIVE)</Q1ViewOpenCvArchivePath>
1213
<Q1ViewOpenCvSha256 Condition="'$(Q1VIEW_OPENCV_SHA256)' != ''">$(Q1VIEW_OPENCV_SHA256)</Q1ViewOpenCvSha256>
1314
<Q1ViewOpenCvInstallRoot Condition="'$(Q1VIEW_OPENCV_ROOT)' != ''">$(Q1VIEW_OPENCV_ROOT)</Q1ViewOpenCvInstallRoot>
14-
<Q1ViewOpenCvInstallRoot Condition="'$(Q1ViewOpenCvInstallRoot)' == ''">$(MSBuildThisFileDirectory).deps\opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt</Q1ViewOpenCvInstallRoot>
15+
<Q1ViewOpenCvInstallRoot Condition="'$(Q1ViewOpenCvInstallRoot)' == ''">$(MSBuildThisFileDirectory).deps\opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt</Q1ViewOpenCvInstallRoot>
1516
<Q1ViewOpenCvBinaryPrefix Condition="'$(Q1ViewOpenCvBinaryPrefix)' == ''">x64\vc16</Q1ViewOpenCvBinaryPrefix>
1617
<Q1ViewOpenCvLibDir>$(Q1ViewOpenCvInstallRoot)\$(Q1ViewOpenCvBinaryPrefix)\staticlib</Q1ViewOpenCvLibDir>
1718
<Q1ViewOpenCvBinDir>$(Q1ViewOpenCvInstallRoot)\$(Q1ViewOpenCvBinaryPrefix)\bin</Q1ViewOpenCvBinDir>
@@ -22,7 +23,7 @@
2223
BeforeTargets="PrepareForBuild"
2324
Condition="'$(Platform)' == 'x64' and (!Exists('$(Q1ViewOpenCvInstallRoot)\include\opencv2\core.hpp') or !Exists('$(Q1ViewOpenCvCoreLib)') or !Exists('$(Q1ViewOpenCvStamp)'))">
2425
<Message Text="Preparing OpenCV $(Q1ViewOpenCvVersion) dependency at $(Q1ViewOpenCvInstallRoot)" Importance="High" />
25-
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)build\Ensure-OpenCvDependency.ps1&quot; -Version &quot;$(Q1ViewOpenCvVersion)&quot; -InstallRoot &quot;$(Q1ViewOpenCvInstallRoot)&quot; -ArchiveUrl &quot;$(Q1ViewOpenCvArchiveUrl)&quot; -ArchivePath &quot;$(Q1ViewOpenCvArchivePath)&quot; -Sha256 &quot;$(Q1ViewOpenCvSha256)&quot; -Configuration &quot;$(Configuration)&quot; -Platform &quot;$(Platform)&quot; -BinaryPrefix &quot;$(Q1ViewOpenCvBinaryPrefix)&quot;" />
26+
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)build\Ensure-OpenCvDependency.ps1&quot; -Version &quot;$(Q1ViewOpenCvVersion)&quot; -Toolset &quot;$(Q1ViewOpenCvToolset)&quot; -InstallRoot &quot;$(Q1ViewOpenCvInstallRoot)&quot; -ArchiveUrl &quot;$(Q1ViewOpenCvArchiveUrl)&quot; -ArchivePath &quot;$(Q1ViewOpenCvArchivePath)&quot; -Sha256 &quot;$(Q1ViewOpenCvSha256)&quot; -Configuration &quot;$(Configuration)&quot; -Platform &quot;$(Platform)&quot; -BinaryPrefix &quot;$(Q1ViewOpenCvBinaryPrefix)&quot;" />
2627
</Target>
2728
<Target Name="Q1ViewCopyOpenCvRuntime"
2829
AfterTargets="Build"

OpenCV4Release.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
<PropertyGroup Label="UserMacros" />
55
<PropertyGroup>
66
<Q1ViewOpenCvVersion Condition="'$(Q1ViewOpenCvVersion)' == ''">4.3.0</Q1ViewOpenCvVersion>
7-
<Q1ViewOpenCvAssetName Condition="'$(Q1ViewOpenCvAssetName)' == ''">Q1View-opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt.zip</Q1ViewOpenCvAssetName>
8-
<Q1ViewOpenCvReleaseTag Condition="'$(Q1ViewOpenCvReleaseTag)' == ''">deps-opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt</Q1ViewOpenCvReleaseTag>
7+
<Q1ViewOpenCvToolset Condition="'$(Q1ViewOpenCvToolset)' == ''">v142</Q1ViewOpenCvToolset>
8+
<Q1ViewOpenCvAssetName Condition="'$(Q1ViewOpenCvAssetName)' == ''">Q1View-opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt.zip</Q1ViewOpenCvAssetName>
9+
<Q1ViewOpenCvReleaseTag Condition="'$(Q1ViewOpenCvReleaseTag)' == ''">deps-opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt</Q1ViewOpenCvReleaseTag>
910
<Q1ViewOpenCvArchiveUrl Condition="'$(Q1VIEW_OPENCV_URL)' != ''">$(Q1VIEW_OPENCV_URL)</Q1ViewOpenCvArchiveUrl>
1011
<Q1ViewOpenCvArchiveUrl Condition="'$(Q1ViewOpenCvArchiveUrl)' == ''">https://github.com/chammoru/Q1View/releases/download/$(Q1ViewOpenCvReleaseTag)/$(Q1ViewOpenCvAssetName)</Q1ViewOpenCvArchiveUrl>
1112
<Q1ViewOpenCvArchivePath Condition="'$(Q1VIEW_OPENCV_ARCHIVE)' != ''">$(Q1VIEW_OPENCV_ARCHIVE)</Q1ViewOpenCvArchivePath>
1213
<Q1ViewOpenCvSha256 Condition="'$(Q1VIEW_OPENCV_SHA256)' != ''">$(Q1VIEW_OPENCV_SHA256)</Q1ViewOpenCvSha256>
1314
<Q1ViewOpenCvInstallRoot Condition="'$(Q1VIEW_OPENCV_ROOT)' != ''">$(Q1VIEW_OPENCV_ROOT)</Q1ViewOpenCvInstallRoot>
14-
<Q1ViewOpenCvInstallRoot Condition="'$(Q1ViewOpenCvInstallRoot)' == ''">$(MSBuildThisFileDirectory).deps\opencv-$(Q1ViewOpenCvVersion)-msvc-x64-static-mt</Q1ViewOpenCvInstallRoot>
15+
<Q1ViewOpenCvInstallRoot Condition="'$(Q1ViewOpenCvInstallRoot)' == ''">$(MSBuildThisFileDirectory).deps\opencv-$(Q1ViewOpenCvVersion)-msvc-$(Q1ViewOpenCvToolset)-x64-static-mt</Q1ViewOpenCvInstallRoot>
1516
<Q1ViewOpenCvBinaryPrefix Condition="'$(Q1ViewOpenCvBinaryPrefix)' == ''">x64\vc16</Q1ViewOpenCvBinaryPrefix>
1617
<Q1ViewOpenCvLibDir>$(Q1ViewOpenCvInstallRoot)\$(Q1ViewOpenCvBinaryPrefix)\staticlib</Q1ViewOpenCvLibDir>
1718
<Q1ViewOpenCvBinDir>$(Q1ViewOpenCvInstallRoot)\$(Q1ViewOpenCvBinaryPrefix)\bin</Q1ViewOpenCvBinDir>
@@ -22,7 +23,7 @@
2223
BeforeTargets="PrepareForBuild"
2324
Condition="'$(Platform)' == 'x64' and (!Exists('$(Q1ViewOpenCvInstallRoot)\include\opencv2\core.hpp') or !Exists('$(Q1ViewOpenCvCoreLib)') or !Exists('$(Q1ViewOpenCvStamp)'))">
2425
<Message Text="Preparing OpenCV $(Q1ViewOpenCvVersion) dependency at $(Q1ViewOpenCvInstallRoot)" Importance="High" />
25-
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)build\Ensure-OpenCvDependency.ps1&quot; -Version &quot;$(Q1ViewOpenCvVersion)&quot; -InstallRoot &quot;$(Q1ViewOpenCvInstallRoot)&quot; -ArchiveUrl &quot;$(Q1ViewOpenCvArchiveUrl)&quot; -ArchivePath &quot;$(Q1ViewOpenCvArchivePath)&quot; -Sha256 &quot;$(Q1ViewOpenCvSha256)&quot; -Configuration &quot;$(Configuration)&quot; -Platform &quot;$(Platform)&quot; -BinaryPrefix &quot;$(Q1ViewOpenCvBinaryPrefix)&quot;" />
26+
<Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)build\Ensure-OpenCvDependency.ps1&quot; -Version &quot;$(Q1ViewOpenCvVersion)&quot; -Toolset &quot;$(Q1ViewOpenCvToolset)&quot; -InstallRoot &quot;$(Q1ViewOpenCvInstallRoot)&quot; -ArchiveUrl &quot;$(Q1ViewOpenCvArchiveUrl)&quot; -ArchivePath &quot;$(Q1ViewOpenCvArchivePath)&quot; -Sha256 &quot;$(Q1ViewOpenCvSha256)&quot; -Configuration &quot;$(Configuration)&quot; -Platform &quot;$(Platform)&quot; -BinaryPrefix &quot;$(Q1ViewOpenCvBinaryPrefix)&quot;" />
2627
</Target>
2728
<Target Name="Q1ViewCopyOpenCvRuntime"
2829
AfterTargets="Build"

build/Build-OpenCvDependency.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
param(
22
[string]$Version = "4.3.0",
33

4+
[string]$Toolset = "v142",
5+
46
[string]$SourceRoot = "",
57

68
[string]$BuildRoot = "",
@@ -160,8 +162,10 @@ $cmake = Get-CMake
160162
$configureStamp = Join-Path $buildRootPath "CMakeCache.txt"
161163
if (Test-Path $configureStamp) {
162164
$cacheText = Get-Content -LiteralPath $configureStamp -Raw
163-
if ($cacheText -notmatch "BUILD_WITH_STATIC_CRT:BOOL=ON") {
164-
Write-Host "Reconfiguring OpenCV because the existing build tree does not use the static CRT"
165+
$toolsetPattern = "CMAKE_GENERATOR_TOOLSET:INTERNAL=$([regex]::Escape($Toolset))(\r?\n|,)"
166+
if ($cacheText -notmatch "BUILD_WITH_STATIC_CRT:BOOL=ON" -or
167+
$cacheText -notmatch $toolsetPattern) {
168+
Write-Host "Reconfiguring OpenCV because the existing build tree does not use $Toolset with the static CRT"
165169
Remove-Item -LiteralPath $buildRootPath -Recurse -Force
166170
if (Test-Path $installRootPath) {
167171
Remove-Item -LiteralPath $installRootPath -Recurse -Force
@@ -177,6 +181,7 @@ if (-not (Test-Path $configureStamp)) {
177181
"-S", $sourceRootPath,
178182
"-B", $buildRootPath,
179183
"-A", $platformName,
184+
"-T", $Toolset,
180185
"-DOpenCV_ARCH=$platformName",
181186
"-DOpenCV_RUNTIME=vc16",
182187
"-DCMAKE_INSTALL_PREFIX=$installRootPath",
@@ -239,7 +244,7 @@ foreach ($configuration in $Configurations) {
239244
}
240245

241246
$stampPath = Join-Path $installRootPath "q1view-opencv-$configuration.stamp"
242-
"OpenCV $Version $configuration $platformName static-crt" | Out-File -LiteralPath $stampPath -Encoding ascii
247+
"OpenCV $Version $configuration $platformName $Toolset static-crt" | Out-File -LiteralPath $stampPath -Encoding ascii
243248
}
244249

245250
$ffmpegDllPath = Join-Path $installRootPath "$binaryPrefix\bin\opencv_videoio_ffmpeg430_64.dll"

build/Ensure-OpenCvDependency.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
param(
22
[string]$Version = "4.3.0",
33

4+
[string]$Toolset = "v142",
5+
46
[Parameter(Mandatory = $true)]
57
[string]$InstallRoot,
68

@@ -63,7 +65,7 @@ function Get-ArchiveFileName {
6365
param([string]$Url)
6466

6567
if ([string]::IsNullOrWhiteSpace($Url)) {
66-
return "Q1View-opencv-$Version-msvc-x64-static-mt.zip"
68+
return "Q1View-opencv-$Version-msvc-$Toolset-x64-static-mt.zip"
6769
}
6870

6971
try {
@@ -76,7 +78,7 @@ function Get-ArchiveFileName {
7678
catch {
7779
}
7880

79-
return "Q1View-opencv-$Version-msvc-x64-static-mt.zip"
81+
return "Q1View-opencv-$Version-msvc-$Toolset-x64-static-mt.zip"
8082
}
8183

8284
function Resolve-Archive {

docs/DEVELOPMENT.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ msbuild Comparer\Comparer.sln /m /restore /p:Configuration=Release /p:Platform=x
1717
```
1818

1919
Normal builds restore prebuilt OpenCV and libheif dependency archives into
20-
`.deps`. Dedicated GitHub Actions workflows create updated dependency archives
21-
when dependency versions change.
20+
`.deps`. The OpenCV archive is built with the VS2019 `v142` toolset so its
21+
static libraries link with VS2019 and newer MSVC toolsets. Dedicated GitHub
22+
Actions workflows create updated dependency archives when dependency versions
23+
or toolsets change.
2224

2325
## Core Regression Tests
2426

0 commit comments

Comments
 (0)