Genex unexpected behavior

This is an example code that creates in windows two static libraries a.lib and b.lib while b.lib is a superset of a.lib with additional custom objects.
I know that this could have been done in a simpler way - although this is to demonstrate the unexpected behavior of some genex, here is the code:

set( custom_objs b.obj)
add_library(a OBJECT a.cpp)
add_custom_target(b ALL
COMMAND ${CMAKE_COMMAND} -E echo “lib /OUT:b.lib ${custom_objs} $<JOIN:<TARGET_OBJECTS:a>, >”
COMMAND lib /OUT:b.lib ${custom_objs} $<JOIN:<TARGET_OBJECTS:a>, >)

The custom target has two commands the first dump the lib command, the second executes.
Well the genex: $Join:..... displays correctly a.obj while in the second command it does not expanded it at all.

Why is it so?

The quotes are not interpreted by the command line tool, but already by CMake.
They are needed for CMakes function argument parser to not interpret the space as delimiter in arguments.

So the right solution is "$<JOIN:$<TARGET_OBJECTS:a>, >", otherwise you end up with two function arguments $<JOIN:$<TARGET_OBJECTS:a>, and >

P.S. The missing $ before <TARGET_OBJECTS> is causing a CMake error.
And I strongly suggest to use CMake add_library instead of creating custom targets.

Thanks Joseph for your answer - so genex work only inside quotes - I missed this detail.
Also yes you are right, a $ was missing in my above example.

Thanks again.

Not GenEx in general.
It’s the whitespace parsed by the CMake language interpreter as delimiter between arguments.

Got it, thanks.