[cmake-developers] Exporting an imported target not supported?
Brad King
brad.king at kitware.com
Tue Mar 12 10:07:24 EDT 2019
On 3/12/19 9:55 AM, Lassi Niemistö wrote:
> is there a technical reason why it would not be a good idea to
> allow exporting the imported targets with all their properties?
We have not thought deeply through the semantics of that in general.
One of the main challenges is relocation handling. Targets installed
by the project have known locations relative to the install prefix
and we expect that everything gets relocated together. Targets from
external places have no such relationship.
If you're hard-coding paths anyway then I suggest simply linking via
absolute path instead of using an imported target. If you do need
usage requirements, do it through a non-imported interface library:
```
add_library(extlib INTERFACE)
target_link_libraries(extlib INTERFACE /path/to/libextlib.so)
target_compile_definitions(extlib INTERFACE ...)
```
That can be installed and exported, and the importing side will
simply use the same absolute path.
-Brad
More information about the cmake-developers
mailing list