Question: Is it possible to have one name for a target and another for the exported one
What i'd like to do is to have a target/library named FooBar
and be able to import it as Foo::Bar
Given the folowing snippets:
add_library(FooBar bar.cpp)
add_library(Foo::Bar ALIAS FooBar)
install(TARGETS FooBar
EXPORT FooBar-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT FooBar-targets
FILE FooBarTargets.cmake
NAMESPACE Foo::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
It works at the build steps (target_link_library(Baz PUBLIC Foo::Bar)
) thanks to the ALIAS
, but the target is exported as Foo::FooBar
in FooBarTargets.cmake
. Is there a way to achieve what i want, or i have no other choice than naming my target/library Bar
instead of FooBar
?
Edited by Debroize René-paul