Skip to content

[Microsoft.DotNet.CMake.Sdk]: Add ability to specify custom filters for NativeProjectReference artifacts #14245

@lambdageek

Description

@lambdageek
  • This issue is blocking
  • This issue is causing unreasonable pain

When using ProjectReference.targets to support NativeProjectReference items, the CopyNativeProjectBinaries target is quite opinionated about what counts as a valid native artifact that will be copied to the current target. It would be nice if it was possible to provide additional filters.

For example, I have a CMakeLists.txt that has the following:

project (bridgeclientJava)

find_package(Java 1.8 COMPONENTS Development)
find_package(JNI)
include(UseJava)

add_jar(bridgeclient BridgeClient.java GENERATE_NATIVE_HEADERS bridgeclientJava-jni)

install_jar(bridgeclient DESTINATION .)

This project only produces a bridgeclient.jar file.

As a result, CopyNativeProjectBinaries has nothing to copy and it ends up erroring out.

As a workaround, I was able to add the following in my consumer project:

    <Target Name="CopyJarFileNativeProjectBinaries"
            BeforeTargets="CopyNativeProjectBinaries">
        <ItemGroup Condition="'$(IsMultiConfigurationGenerator)' != 'true'">
            <NativeProjectBinariesMatchedJAR Include="$(NativeProjectOutputFolder)\*.*" />

            <!-- Filter java JAR files -->
            <NativeProjectBinariesJarFilter Condition="'%(Extension)' == '.jar'" Include="@(NativeProjectBinariesMatchedJAR)" />

            <!-- Merge the filtered lists -->
            <NativeProjectBinaries Include="@(NativeProjectBinariesJarFilter)" />
        </ItemGroup>
    </Target>

However it would be nice if there was a general mechanism for specifying additional filters. (ideally in the CMakeProject - so that additional filters are centralized in the definining project, not as metadata on every single NativeProjectReference)

Or perhaps the CMake SDK can use some other mechanism to discover which artifacts were produced by the build target

Metadata

Metadata

Assignees

Labels

area-Infrastructure-librariesArea maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions