Supporting imported targets with and without namespaces
We are cleaning up the cmake in our project. Targets are not currently exported with namespaces, but ideally should be. However, we have enough users based on the old cmake that we don’t want to require people
to use the namespaced target (for a while).
I couldn’t find recommendations on this in documentation or list archives.
Even when the exported target is namespace::imported_lib, this still seems to work:
which I did not understand.
AFAIK, you cannot ALIAS an imported target in the config file:
add_library(imported_lib ALIAS namespace::imported_lib)
so that both the namespace and non-namespaced versions are valid
It did work to use the following in the config file:
target_link_libraries(imported_lib INTERFACE namespace::imported_lib)
but this just feels like the wrong way to do it