Short target names and exports

Is it okay to use short target names such as “base” in libraries as long as they are unique to the library? The imported targets are made unique with a namespace prefix, e.g. Prefix::base.

Background: Target names could be made more unique by also prepending the prefix, e.g. prefix-base, however when using install(TARGETS prefix-base) together with install(EXPORT NAMESPACE Prefix::) I end up with the imported target name Prefix::prefix-base. I would prefer the name Prefix::base.

The generic name “base” on the other hand makes collisions with other projects likely when added as subdirectory. Is there another way to realize the imported target name Prefix::base in my CMake package while keeping my target name prefix-base?

You probably want the EXPORT_NAME target property.

1 Like

There is a property for everything :slight_smile: Thanks a lot, this is exactly what I was looking for.