<div dir="ltr">TL;DR:<br><br> - For a project thing I get thingTargets.cmake when I install EXPORT it<br> - thingTargets.cmake sets _IMPORT_PREFIX<br> - thingTargets.cmake loads files thingTargets-*.cmake<br><br>Can I create and install thingTargets-someName.cmake which uses _IMPORT_PREFIX to "hook" into above mechanism? Or is this likely to break / change in the future?<br><br>Longer version:<br><br>I really like that you can use the exported targets of cmake even when still in a staging directory and not installed. Example:<br><br># in thing project<br>mkdir thing-build; cd thing-build<br>cmake .. -DCMAKE_INSTALL_PREFIX=""<br>make<br># creates /path/to/staging/lib/cmake/thing/lib{Config,Targets}.cmake and friends<br>make install DESTDIR=/path/to/staging<br><br># in user project<br>mkdir user-build<br>cmake .. -Dthing_DIR=/path/to/staging/lib/cmake/thing<br>make # correctly uses libraries and headers from /path/to/staging/<br><br>Looking at /path/to/staging/lib/cmake/thing/libTargets.cmake I can see that it calculates an _IMPORT_PREFIX variable (in this case to /path/to/staging/ while not yet installed). Also it loads files named libTargets-*.cmake (of which there's only one for me, namely libTargets-noconfig.cmake).<br><br>Can I install a file libTargets-someName.cmake? In this file I'd have access to the _IMPORT_PREFIX variable to e.g. set paths:<br><br>target_link_options(thing::lib<br>  INTERFACE<br>  -T ${_IMPORT_PREFIX}/share/link.ld)<br><br>Larger example at <a href="https://github.com/musteresel/cmake-multiple-example-research">https://github.com/musteresel/cmake-multiple-example-research</a><br><br>Best,<br>Daniel</div>