On 02/24/2015 05:25 PM, Stephen Kelly wrote:
>> Until that problem is solved we cannot make object libraries
>> implicitly offer their objects just through tll().
> 
> Honestly, the problem is still not clear to me.

Consider an object library with some usage requirements:

 add_library(objlib OBJECT ...)
 target_compile_definitions(objlib PUBLIC MYDEF)

Now try using that library and assume that tll() takes the objects
without explicit $<TARGET_OBJECTS:objlib> in the sources:

 add_library(mylib SHARED ...)
 target_link_libraries(mylib PUBLIC objlib)

We link publicly to forward the usage requirements of objlib through
mylib.  Now consumers of mylib will get objlib's objects too.  That
is not desired.  It is the same problem as transitive interface
sources.

My solution to that when first designing object libraries was to
disallow the tll() altogether and require the consumer that wants
the object files to reference them as $<TARGET_OBJECTS:objlib>
sources explicitly.  Of course that pre-dated usage requirements.
Now we want to allow

 add_library(mylib SHARED ... $<TARGET_OBJECTS:objlib> ...)
 target_link_libraries(mylib PUBLIC objlib)

to put the objects in mylib and also forward usage requirements.
So long as the objlib does not have any INTERFACE_SOURCES then
it will work well.

What I envision for the future is:

 add_library(objlib OBJECT ...)
 target_compile_definitions(objlib PUBLIC MYDEF)
 target_sources(objlib INTERFACE $<TARGET_OBJECTS:objlib>)

That will allow consumers of objlib to get the objects through
tll() just like any other INTERFACE_SOURCES.  What I said in my
previous response was that until the transitive interface sources
problem is solved I'd rather not allow this.  OTOH, since this
population of INTERFACE_SOURCES is not automatic perhaps it is
simplest and most consistent to go ahead and allow projects to
do this.  The problem will be no worse than for other interface
sources.

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to