Skip to content

Commit

Permalink
Pass down AdditionalProperties for NativeProjectReferences. Precalcul…
Browse files Browse the repository at this point in the history
…ate if the generator is multi-config so the CopyNativeProjectBinaries target doesn't need to call into the CMake project (#7237)
  • Loading branch information
jkoritzinsky authored Apr 15, 2021
1 parent 93a6389 commit 4fdee21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</PropertyGroup>
</Target>

<Target Name="GetOutputPathForProjectReference" DependsOnTargets="GetRootCMakeListsDirectory;ResolveVSGenerator" Returns="$(_CMakeProjectReferenceFilesLocation)">
<Target Name="GetOutputPathForProjectReference" DependsOnTargets="GetRootCMakeListsDirectory;ResolveVSGenerator;IsMultiConfigurationGenerator" Returns="@(_CMakeProjectReferenceFilesLocationItem)">
<PropertyGroup>
<_NormalizedReferencedCMakeListsDirectory>$([System.IO.Path]::GetDirectoryName($(ReferencedCMakeLists)))</_NormalizedReferencedCMakeListsDirectory>
</PropertyGroup>
Expand All @@ -83,6 +83,9 @@
<_CMakeProjectReferenceFilesLocation
Condition="'$(_CMakeMultiConfigurationGenerator)' == 'true'">$([MSBuild]::NormalizePath('$(_CMakeProjectReferenceFilesLocation)','$(Configuration)'))</_CMakeProjectReferenceFilesLocation>
</PropertyGroup>
<ItemGroup>
<_CMakeProjectReferenceFilesLocationItem Include="$(_CMakeProjectReferenceFilesLocation)" IsMultiConfigurationGenerator="_CMakeMultiConfigurationGenerator" />
</ItemGroup>
</Target>

<Target Name="_ResolveVSCompilerToolchainForNonVSGenerators"
Expand Down
18 changes: 8 additions & 10 deletions src/Microsoft.DotNet.CMake.Sdk/sdk/ProjectReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
</Target>

<Target Name="CopyNativeProjectBinaries">
<MSBuild Projects="$(ReferencedCMakeProject)"
Targets="IsMultiConfigurationGenerator">
<Output TaskParameter="TargetOutputs" PropertyName="_IsMultiConfigurationGenerator" />
</MSBuild>

<ItemGroup Condition="'$(_IsMultiConfigurationGenerator)' == 'true'">
<ItemGroup Condition="'$(IsMultiConfigurationGenerator)' == 'true'">
<NativeProjectBinaries Include="$(NativeProjectOutputFolder)\*.*" />
</ItemGroup>
<ItemGroup Condition="'$(_IsMultiConfigurationGenerator)' != 'true'">
<ItemGroup Condition="'$(IsMultiConfigurationGenerator)' != 'true'">

<!-- ############################################################### -->
<!-- The following is required because the single configuration -->
Expand Down Expand Up @@ -122,12 +117,14 @@

<MSBuild Projects="%(NativeProjectReferenceNormalized.CMakeProject)"
Targets="GetOutputPathForProjectReference"
Properties="ReferencedCMakeLists=%(NativeProjectReferenceNormalized.Identity)">
Properties="ReferencedCMakeLists=%(NativeProjectReferenceNormalized.Identity);%(NativeProjectReferenceNormalized.AdditionalProperties)">
<Output TaskParameter="TargetOutputs" ItemName="NativeProjectOutputFoldersToCopy" />
</MSBuild>

<ItemGroup>
<_NativeProjectReferenceToBuild Include="%(NativeProjectReferenceNormalized.CMakeProject)" Condition="'%(NativeProjectReferenceNormalized.BuildNative)' == 'true'" />
<_NativeProjectReferenceToBuild Include="%(NativeProjectReferenceNormalized.CMakeProject)"
Condition="'%(NativeProjectReferenceNormalized.BuildNative)' == 'true'"
AdditionalProperties="%(NativeProjectReferenceNormalized.AdditionalProperties)" />
</ItemGroup>

<RemoveDuplicates Inputs="@(_NativeProjectReferenceToBuild)">
Expand All @@ -142,7 +139,8 @@
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="CopyNativeProjectBinaries"
Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity);
ReferencedCMakeProject=%(NativeProjectOutputFoldersToCopy.MSBuildSourceProjectFile)"
ReferencedCMakeProject=%(NativeProjectOutputFoldersToCopy.MSBuildSourceProjectFile);
IsMultiConfigurationGenerator=%(NativeProjectOutputFoldersToCopy.IsMultiConfigurationGenerator)"
Condition="'@(NativeProjectReference)' != ''" />

</Target>
Expand Down

0 comments on commit 4fdee21

Please sign in to comment.