@@ -122,7 +122,8 @@ function Invoke-BatchFile {
122122function Add-Signing {
123123 param (
124124 [String ]$Directory ,
125- [String ]$ProjectName
125+ [String ]$ProjectName ,
126+ [Boolean ]$IsArm64 = $false
126127 )
127128
128129 $xml = [xml ](Get-Content " $Directory \$ProjectName .vcxproj" )
@@ -140,7 +141,14 @@ function Add-Signing {
140141 $AdditionalOptions.set_InnerXML (" /ZH:SHA_256 /guard:cf /Qspectre /Zi %(AdditionalOptions)" );
141142 $ClCompile.AppendChild ($AdditionalOptions ) | Out-Null
142143 $AdditionalLinkOptions = $xml.CreateElement (" AdditionalOptions" , " http://schemas.microsoft.com/developer/msbuild/2003" )
143- $AdditionalLinkOptions.set_InnerXML (" /Profile /guard:cf /DYNAMICBASE /CETCOMPAT %(AdditionalOptions)" );
144+
145+ # Only use /CETCOMPAT flag for non-arm64.
146+ if ($IsArm64 ) {
147+ $AdditionalLinkOptions.set_InnerXML (" /Profile /guard:cf /DYNAMICBASE %(AdditionalOptions)" );
148+ } else {
149+ $AdditionalLinkOptions.set_InnerXML (" /Profile /guard:cf /DYNAMICBASE /CETCOMPAT %(AdditionalOptions)" );
150+ }
151+
144152 $Link = $xml.CreateElement (" Link" , " http://schemas.microsoft.com/developer/msbuild/2003" )
145153 $Link.AppendChild ($AdditionalLinkOptions ) | Out-Null
146154 $BuildGroup.AppendChild ($ClCompile ) | Out-Null
@@ -196,7 +204,8 @@ function Build-Binaries {
196204 [String ]$BuildToolset ,
197205 [String ]$Platform ,
198206 [Boolean ]$DynamicLibraryLinkage ,
199- [Boolean ]$DynamicCRTLinkage
207+ [Boolean ]$DynamicCRTLinkage ,
208+ [Boolean ]$IsArm64 = $false
200209 )
201210
202211 $Dir = Create- WorkingDirectory - Prefix " build" - ToolsetName $ToolsetName - BuildToolset $BuildToolset - Platform $Platform `
@@ -213,11 +222,12 @@ function Build-Binaries {
213222 $CMakeArgs += " -D" , " BUILD_SHARED_LIBS=$ ( Convert-BooleanToOnOff $DynamicLibraryLinkage ) "
214223 $CMakeArgs += " -D" , " gtest_force_shared_crt=$ ( Convert-BooleanToOnOff $DynamicCRTLinkage ) "
215224 $CMakeArgs += " -D" , " CMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
225+ $CMakeArgs += " -D" , " CMAKE_SYSTEM_VERSION='10.0.26100.0'"
216226 $CMakeArgs += $CMakeDir
217227 Invoke-Executable cmake $CMakeArgs
218228
219- Add-Signing - Directory $Dir - ProjectName " gtest"
220- Add-Signing - Directory $Dir - ProjectName " gtest_main"
229+ Add-Signing - Directory $Dir - ProjectName " gtest" - IsArm64 $IsArm64
230+ Add-Signing - Directory $Dir - ProjectName " gtest_main" - IsArm64 $IsArm64
221231
222232 Invoke-Executable msbuild @ (" gtest.vcxproj" , " /p:Configuration=Debug" )
223233 Invoke-Executable msbuild @ (" gtest_main.vcxproj" , " /p:Configuration=Debug" )
@@ -311,14 +321,14 @@ function Build-NuGet {
311321 Copy-CreateItem - Path " $BuildPath \RelWithDebInfo\gtest_main.dll" - Destination " ..\a\drop\gtest_main.dll"
312322 } else {
313323 Copy-CreateItem - Path " $BuildPath \Debug\gtestd.lib" - Destination " $DestinationPath \Debug\gtestd.lib"
314- Copy-CreateItem - Path " $BuildPath \gtest.dir\ Debug\gtest .pdb" - Destination " $DestinationPath \Debug\gtest.pdb"
324+ Copy-CreateItem - Path " $BuildPath \Debug\gtestd .pdb" - Destination " $DestinationPath \Debug\gtest.pdb"
315325 Copy-CreateItem - Path " $BuildPath \Debug\gtest_maind.lib" - Destination " $DestinationPath \Debug\gtest_maind.lib"
316- Copy-CreateItem - Path " $BuildPath \gtest_main.dir\ Debug\gtest_main .pdb" - Destination " $DestinationPath \Debug\gtest_main.pdb"
326+ Copy-CreateItem - Path " $BuildPath \Debug\gtest_maind .pdb" - Destination " $DestinationPath \Debug\gtest_main.pdb"
317327
318328 Copy-CreateItem - Path " $BuildPath \RelWithDebInfo\gtest.lib" - Destination " $DestinationPath \Release\gtest.lib"
319- Copy-CreateItem - Path " $BuildPath \gtest.dir\ RelWithDebInfo\gtest.pdb" - Destination " $DestinationPath \Release\gtest.pdb"
329+ Copy-CreateItem - Path " $BuildPath \RelWithDebInfo\gtest.pdb" - Destination " $DestinationPath \Release\gtest.pdb"
320330 Copy-CreateItem - Path " $BuildPath \RelWithDebInfo\gtest_main.lib" - Destination " $DestinationPath \Release\gtest_main.lib"
321- Copy-CreateItem - Path " $BuildPath \gtest_main.dir\ RelWithDebInfo\gtest_main.pdb" - Destination " $DestinationPath \Release\gtest_main.pdb"
331+ Copy-CreateItem - Path " $BuildPath \RelWithDebInfo\gtest_main.pdb" - Destination " $DestinationPath \Release\gtest_main.pdb"
322332 }
323333 }
324334
@@ -352,7 +362,7 @@ function Build-BinariesAndNuGet {
352362 $BuildDir64 = Build-Binaries - ToolsetName $ToolsetName - BuildToolset $BuildToolset - Platform " x64" - DynamicLibraryLinkage $DynamicLibraryLinkage `
353363 - DynamicCRTLinkage $DynamicCRTLinkage
354364 $BuildDirARM64 = Build-Binaries - ToolsetName $ToolsetName - BuildToolset $BuildToolset - Platform " arm64" - DynamicLibraryLinkage $DynamicLibraryLinkage `
355- - DynamicCRTLinkage $DynamicCRTLinkage
365+ - DynamicCRTLinkage $DynamicCRTLinkage - IsArm64 $true
356366 Build-NuGet - BuildDir32 $BuildDir32 - BuildDir64 $BuildDir64 - BuildDirARM64 $BuildDirARM64 - ToolsetName $ToolsetName `
357367 - BuildToolset $BuildToolset - DynamicLibraryLinkage $DynamicLibraryLinkage - DynamicCRTLinkage $DynamicCRTLinkage - OutputDir $OutputDir | Out-Null
358368}
@@ -384,9 +394,9 @@ function Main {
384394
385395 $OutputDir = " GoogleTestAdapter\Packages"
386396
387- Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v141 " - DynamicLibraryLinkage $false - DynamicCRTLinkage $true - OutputDir $OutputDir
388- Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v141 " - DynamicLibraryLinkage $false - DynamicCRTLinkage $false - OutputDir $OutputDir
389- Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v141 " - DynamicLibraryLinkage $true - DynamicCRTLinkage $true - OutputDir $OutputDir
397+ Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v143 " - DynamicLibraryLinkage $false - DynamicCRTLinkage $true - OutputDir $OutputDir
398+ Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v143 " - DynamicLibraryLinkage $false - DynamicCRTLinkage $false - OutputDir $OutputDir
399+ Build-BinariesAndNuGet - ToolsetName " v140" - BuildToolset " v143 " - DynamicLibraryLinkage $true - DynamicCRTLinkage $true - OutputDir $OutputDir
390400
391401 " Success"
392402}
0 commit comments