Exporting Targets

BLT provides several built-in targets for commonly used libraries:


Available when ENABLE_MPI is ON


Available when ENABLE_OPENMP is ON

cuda and cuda_runtime

Available when ENABLE_CUDA is ON

blt_hip and blt_hip_runtime

Available when ENABLE_HIP is ON

These targets can be made exportable in order to make them available to users of your project via CMake’s install() command. Setting BLT’s BLT_EXPORT_THIRDPARTY option to ON will mark all active targets in the above list as EXPORTABLE (see the blt_import_library API documentation for more info).


As with other EXPORTABLE targets created by blt_import_library, these targets should be prefixed with the name of the project. Either the EXPORT_NAME target property or the NAMESPACE option to CMake’s install command can be used to modify the name of an installed target.


If a target in your project is added to an export set, any of its dependencies marked EXPORTABLE must be added to the same export set. Failure to add them will result in a CMake error in the exporting project.


The recommended usage of the HIP targets is via the blt::hip and blt::hip_runtime aliases. Alias targets cannot be exported, so the blt_hip/blt_hip_runtime names can be used for this purpose.

Typical usage of the BLT_EXPORT_THIRDPARTY option is as follows:

# BLT configuration - enable MPI
# and mark the subsequently created MPI target as exportable
# Both of the above must happen before SetupBLT.cmake is included

# Later, a project might mark a target as dependent on MPI
blt_add_executable( NAME    example_1
                    SOURCES example_1.cpp
                    DEPENDS_ON blt::mpi )

# Add the example_1 target to the example-targets export set
install(TARGETS example_1 EXPORT example-targets)

# Add BLT's targets to the same export set - this is required
# because the mpi target was marked exportable
blt_export_tpl_targets(EXPORT example-targets)

To avoid collisions with projects that import “example-targets”, it is recommended to provide a namespace for the mpi target:

blt_export_tpl_targets(EXPORT example-targets NAMESPACE example)

With this approach the example_1 target’s exported name is unchanged - a project that imports the example-targets export set will have example_1 and example::mpi targets made available. The imported example_1 will depend on example::mpi.