OBJECT libraries process objects from dependencies
The case reported in !3838 (comment 629347) exposes an existing problem when object libraries link to each other. Consider the case
add_library(A OBJECT a.c)
add_library(B OBJECT b.c)
target_link_libraries(B PRIVATE A)
In this case, B
's objects should compile with the usage requirements from A
but as documented does not do anything with A
's object files. However, the current implementation of cmGeneratorTarget::GetSourceFilePaths
, responsible for generating the list of source files used to build a target, collects TARGET_OBJECTS
of link dependencies even for object libraries.
This does not cause any effects because the object libraries do not have a link step that would use the extra objects, but it does have some problems:
- With the VS generator one can see
a.obj
listed inB.vcxproj
even though it is not a source of that target. - The implementation of
cmGeneratorTarget::GetLanguages
considers the transitive closure of object libraries' object files unnecessarily (and perhaps incorrectly). This leads to the long generate times reported in the above-mentioned comment.