Skip to content

Commit d5a2fb6

Browse files
committed
Fix Google Test project builds with ARM64
Add condition to create pch file when using ARM64. Previously, ARM64 builds also failed because we passed static $ and $ string into the xml chunk which could not be read, so now we use dynamic runtime values and pass those strings into the xml chunks.
1 parent 7855799 commit d5a2fb6

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

GoogleTestAdapter/GoogleTestProjectTemplate/GoogleTest.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
4444
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
4545
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
46+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Create</PrecompiledHeader>
47+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Create</PrecompiledHeader>
4648
</ClCompile>
4749
</ItemGroup>
4850
<ItemDefinitionGroup />

GoogleTestAdapter/NewProjectWizard/WizardImplementation.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ public class WizardImplementation : IWizard
2323
private const string TargetPlatformVersion = "$targetplatformversion$";
2424
private const string WizardData = "$wizarddata$";
2525
private const string RuntimeDebug = "$rtdebug$";
26+
private string RuntimeDebugValue = "MultiThreadedDebugDLL";
2627
private const string RuntimeRelease = "$rtrelease$";
28+
private string RuntimeReleasevalue = "MultiThreadedDLL";
2729
private const string RunSilent = "$runsilent$";
2830
private const string ARM64DebugPlatform = "$arm64debugplatform$";
29-
private string arm64DebugXMLChunk = " <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\"> <ClCompile> <PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>ARM64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>$rtdebug$</RuntimeLibrary> <WarningLevel>Level3</WarningLevel> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <SubSystem>Console</SubSystem> </Link> </ItemDefinitionGroup>";
31+
private string arm64DebugXMLChunk = $" <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\"> <ClCompile> <PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>ARM64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>{RuntimeDebugValue}</RuntimeLibrary> <WarningLevel>Level3</WarningLevel> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <SubSystem>Console</SubSystem> </Link> </ItemDefinitionGroup>";
3032
private const string ARM64ReleasePlatform = "$arm64releaseplatform$";
31-
private string arm64ReleaseXMLChunk = " <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\"> <ClCompile> <PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PreprocessorDefinitions>ARM64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>$rtrelease$</RuntimeLibrary> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <SubSystem>Console</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> </Link> </ItemDefinitionGroup>";
33+
private string arm64ReleaseXMLChunk = $" <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\"> <ClCompile> <PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PreprocessorDefinitions>ARM64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>{RuntimeReleasevalue}</RuntimeLibrary> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <SubSystem>Console</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> </Link> </ItemDefinitionGroup>";
3234
private const string ARM64Config = "$arm64config$";
3335
private string arm64ConfigXML = "<ProjectConfiguration Include=\"Debug|ARM64\"> <Configuration>Debug</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include=\"Release|ARM64\"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration>";
3436
private List<Project> projects = new List<Project>();
@@ -153,15 +155,18 @@ public void RunStarted(object automationObject,
153155

154156
if (configurationData.IsRuntimeStatic)
155157
{
156-
replacementsDictionary[RuntimeRelease] = "MultiThreaded";
157-
replacementsDictionary[RuntimeDebug] = "MultiThreadedDebug";
158+
RuntimeReleasevalue = "MultiThreaded";
159+
RuntimeDebugValue = "MultiThreadedDebug";
158160
}
159161
else
160162
{
161-
replacementsDictionary[RuntimeRelease] = "MultiThreadedDLL";
162-
replacementsDictionary[RuntimeDebug] = "MultiThreadedDebugDLL";
163+
RuntimeReleasevalue = "MultiThreadedDLL";
164+
RuntimeDebugValue = "MultiThreadedDebugDLL";
163165
}
164166

167+
replacementsDictionary[RuntimeRelease] = RuntimeReleasevalue;
168+
replacementsDictionary[RuntimeDebug] = RuntimeDebugValue;
169+
165170
if (!isPlatformSet)
166171
{
167172
IEnumerable<TargetPlatformSDK> platformSdks = ToolLocationHelper.GetTargetPlatformSdks();

0 commit comments

Comments
 (0)