[cmake-developers] Requesting Advice: Installing object files

Brad King brad.king at kitware.com
Fri Jan 20 09:12:25 EST 2017


On 01/18/2017 03:14 PM, Ben Boeckel wrote:
> So I talked with Rob about this a bit and the INTERFACE bit is actually
> the *exporting* of the target. Installing the target can install the
> objects. I think the way this could work is that if it is installed, the
> objects go and if they are exported,

I agree something along these lines is the way to go.  The limitation of
not being able to install object libraries is only there because when
object libraries were first implemented they had a very specific purpose
and we didn't want to have to delay them just to think through all the
semantics of installation.

> they are exported as an INTERFACE library which supports a
> $<TARGET_OBJECTS> genex (and if the target is not installed, it
> wouldn't work).

We should also consider exporting them as something like

  add_library(myobjlib OBJECT IMPORTED)
  set_property(TARGET myobjlib PROPERTY IMPORTED_OBJECTS ...)

There is no reason it has to specifically be an INTERFACE library.
In fact if we don't also work out target_link_libraries semantics
for object libraries then we can't export them as INTERFACE libraries
or tll() with them would have to be defined.

-Brad



More information about the cmake-developers mailing list