Skip to content

[FEA] CMake: Allow subproject to install MatX files #1150

@tbirdso

Description

@tbirdso

Is your feature request related to a problem? Please describe.

Context: Downstream projects may want to consume MatX as a CMake subproject and then install the MatX component for redistribution. Holoscan SDK retrieves and builds with MatX with FetchContent (via rapids_cpm_find) and then embeds MatX headers in resulting binary packages for developer convenience. (See link)

Issue: MatX today does not support generating "matx-config.cmake" if MatX is consumed as a subproject in some external build. Config file logic is gated behind the MatX NOT_SUBPROJECT variable here.

Describe the solution you'd like
Allow the developer to set explicitly whether MatX CMake config files should be generated, falling back to previous behavior as needed.

Implementation suggestion by @jcfr:

if (NOT DEFINED MATX_GENERATE_CONFIG)
  # Generate config files if the user isn't adding this as a subdirectory. At this point our transitive target
  # should have all build properties needed based on the options passed in.
  set(MATX_GENERATE_CONFIG ${PROJECT_IS_TOP_LEVEL})
endif()

Describe alternatives you've considered
Workaround: Patch MatX CMakeLists.txt in downstream FetchContent to override NOT_SUBPROJECT behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions