[CMake] add_library object argument question

Vania Joloboff vania.joloboff at inria.fr
Mon Jan 25 09:34:11 EST 2016


Hi

In a library project there are two level of subdirectories that contain 
modules
to be included into the main library.
In other words, directory lib contains subdirectories foo and bar
Subdirectory foo contains A and B.
Subdirectory bar contains C and D.
All of the objects from A, B, C and D must belong to the library

I understand I can use at the bottom levels A, B, C, D
  add_library() with the OBJECT argument
and I should be able to use add_library() in the top directory
to collect all of the object files from the subdirectories

add_library(... $<TARGET_OBJECTS:some_name> ...)

for each of the sub directories. But the documentation is unclear
about the naming schema to use. What is the syntax/meaning of some_name ?

add_library(... $<TARGET_OBJECTS:foo/A> $<TARGET_OBJECTS:foo/B> 
$<TARGET_OBJECTS:bar/C> $<TARGET_OBJECTS:bar/D> ...)

Or I need to gather at level foo and bar the objects from bottom layer
and recursively make them go up one level by one level ?

Thanks


More information about the CMake mailing list