Hi everyone, something that looks basic and as a new one to cmake, I may miss:
I have two directories A and B
B is a subdirectory of A
Both have their own cmake file:
add_library(lib-b OBJECT b1.cpp b2.obj)
and this is it. Very simple case
. lib-a is a static library that needs to be linked with lib-b
. lib-b has b1.cpp and b2.obj as source files because b2.obj is generated by a custom rule.
. lib-b is defined as OBJECT and not STATIC since there is no way to tell cmake to link it to lib-a.
You even can’t push the hard code library file path into target_link_library; OBJECT is the way to go.
. In the link command that builds lib-a I can see that b1.obj is included but not b2.obj just as if $<TARGET_OBJECTS:lib-b> includes b1.obj but does not include b2.obj such that finally lib-a is incomplete
There does not seem to be a way to pass a variable from directory B to directory A: this variable would
include the custom object files and I could have added the list to lib-a’s sources.
Am I missing some basic mechanism of cmake since this seems a basic construct?
Thanks in advance for any suggestion