[cmake-developers] External objects with IDE generators

Stephen Kelly steveire at gmail.com
Thu Feb 27 03:32:48 EST 2014


Hi,

Part of the work on the SOURCES genex feature is that I want to have uniform 
handling of it.

So

 add_library(ObjLib OBJECT a.cpp b.cpp)
 add_executable(exec c.cpp d.o e.cpp $<TARGET_OBJECTS:ObjLib> f.cpp)

 file(GENERATE OUTPUT exec_files CONTENT $<TARGET_PROPERTY:exec,SOURCES>)

will result in a file containing

 c.cpp
 d.o
 e.cpp
 a.o
 b.o
 f.cpp

by a simple evaluation of the property as a genex. Similarly, generators 
should get external objects of a target by calling GT->GetExternalObjects(), 
which will output d.o, a.o, b.o without caring whether the files were listed 
explicitly (like d.o) or via an OBJECT_LIBRARY (like a.o and b.o). The 
separate infrastructure of GT->UseObjectLibraries etc could then be removed. 
The UseObjectLibraries is problematic because it uses containers populated 
up-front instead of on-demand with a config and head cmTarget. It should be 
possible to do this for example:

 set(exeOnly $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)

 INTERFACE_SOURCES $<${exeOnly},$<TARGET_OBJECTS:ObjLib>>

This change seems unproblematic with the makefile and ninja generators. The 
IDE generators are problematic though. 

'git grep GetExternalObjects' shows that the IDEs mostly don't call 
GetExternalObjects at all. Xcode does it's own thing entirely. VS10 gets 
External objects, but treats them very differently to objects from 
OBJECT_LIBRARY targets. 

I'm not familiar with those generators or the IDEs, so I don't know where to 
go from here.

Thanks,

Steve.




More information about the cmake-developers mailing list