- xxx is a custom target with custom link command
- xlib is an OBJECT library with say two objects a.obj and b.obj
I am using the following code:
add_custom_command(
TARGET xxx
PRE_BUILD
COMMENT ${CMAKE_COMMAND} -E echo “$<TARGET_OBJECTS:${xlib}>” >> listfile.txt
COMMAND ${CMAKE_COMMAND} -E echo “$<TARGET_OBJECTS:${xlib}>” >> listfile.txt)
In this case the list file is constructed as expected with the following content:
a.obj;b.obj
The comment generated is also as expected.
Although we need the list file not to have those ; character and with a new line between each file so I thought to use the JOIN function in the following way:
add_custom_command(
TARGET xxx
PRE_BUILD
COMMENT ${CMAKE_COMMAND} -E echo “$<JOIN:$<TARGET_OBJECTS:${xlib}>,\n>” >> listfile.txt
COMMAND ${CMAKE_COMMAND} -E echo “$<JOIN:$<TARGET_OBJECTS:${xlib}>,\n>” >> listfile.txt)
Well in this case the comment generated is as expected but the list file is empty…
Any idea will be welcome.
Thanks,
Serge