How can I get the objlist from the generator-expressions $<TARGET_OBJECTS:objLib>

I want to get the obj file location and use it for the depends in the add_custom_command.
The question is:
1.how to process the $<TARGET_OBJECTS:objLib> to get specific location,like this
$<TARGET_OBJECTS:objLib> is the list of a/a.o b/b.o c/c.o,and I need to get the a/a.o
2.Is there any else way to do this?

thanks

Since CMake 3.15 (https://cmake.org/cmake/help/v3.15/manual/cmake-generator-expressions.7.html#string-transformations), you can use $<FILTER:list,INCLUDE|EXCLUDE,regex> to filter items in or out of a generator expression. For instance:

$<FILTER:$<TARGET_OBJECTS:objLib>,INCLUDE,a/>

I hope this helps.

For example
aaaa/dddd/ffff/a.o cccc/hhhhh/llll/b.o
But I do not know the directory name,and I just know the a.o,how can I get the whole aaaa/dddd/ffff/a.o

I tried this
DEPENDS $<FILTER:$<TARGET_OBJECTS:objLib>,INCLUDE,root/>

and got the error
$<FILTER:$<TARGET_OBJECTS:objLib>,INCLUDE,root/>

Expression did not evaluate to a known generator expression

Which version of CMake are you using?

3.14

Sorry,I have just saw you said the version is CMake 3.15.I will try.
thanks

Now,I got the cmake generate ok.But how to deal with the below case
For example
aaaa/dddd/ffff/a.o cccc/hhhhh/llll/b.o
But I do not know the directory name,and I just know the a.o,how can I get the whole aaaa/dddd/ffff/a.o

I guess something like

$<FILTER:$<TARGET_OBJECTS:objLib>,INCLUDE,/a.o>

would work.

It does work.
Thank you very much.

Hi I have a similar problem but i have multiple directories linked to a specific target and I need to get all the object files from all the related directories. So I have A/aaa_a/testing/a_a.o , A/aaa_b/testing/a_b.o, A/aaa_c/testing/a_c.o, A/aaa_d/testing/a_d.o and i need all the a_a.o,a_b.o,a_c.o,a_d.o using the generator expressions $<TARGET_OBJECTS:A>, please help!