Custom command OUTPUTS not added to OBJECT Library's TARGET_OBJECTS

I have add_custom_command running objcopy to make some json files linkable. The object files get generated correctly, but when I pass a list of them to add_library(jsons OBJECT ${OUTPUT_FILES}), they don’t seem to get added to TARGET_OBJECTS.

add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_OBJECTS:jsons>") causes make genexdebug to print an empty line.

The docs for the GENERATED property sure make it sound like this should work:

When a generated file created as the OUTPUT of an add_custom_command() command is explicitly listed as a source file for any target in the same directory scope (which usually means the same CMakeLists.txt file), CMake will automatically create a dependency to make sure the file is generated before building that target.

I’m on CMake 3.17.5 (via CLion).

TARGET_OBJECTS is just the list of objects that CMake handles the builds for itself. Support for adding custom objects into that genex results would be a new feature request (and would probably require a policy).

However, there are usually better ways of doing this (from a cross-platform point of view at least). VTK has vtkEncodeString to do this. If you’re using Qt, embedding via .qrc file would also be more cross-platform. This usecase has also been discussed here before.

I’d considered reading the files in CMake and outputting them into source files, but I’d really rather not write c in strings in a cmake file when objcopy gives me everything I need already. I can easily add my generated files to my linker commands myself, I was hoping there was a way to have the OUTPUT(s) of a custom command still get added to a library if they’re binary and not source files.

Edit:
To help reinforce my first point (and in case anyone else stumbles across this), this is my working solution:

file(GLOB SERVICES services/*.json)

foreach (FILE IN LISTS SERVICES)
    get_filename_component(SERVICE ${FILE} NAME)
    set(OUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SERVICE}.obj")
    add_custom_command(OUTPUT ${OUT_FILE}
            COMMAND "${CMAKE_OBJCOPY}" --input-target binary --output-target elf32-littlearm --binary-architecture arm ${SERVICE} ${OUT_FILE}
            DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/services/${SERVICE}"
            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/services"
            )
    list(APPEND OUTPUT_FILES ${OUT_FILE})
endforeach ()

add_library(prv_services OBJECT ${OUTPUT_FILES})
# add_library won't actually pass binary files to the linker (only files its compiled), so link against them directly.
target_link_libraries(${PROJECT_NAME} PRIVATE prv_services ${OUTPUT_FILES})

I expect not to have to manually pass the object files to the linker, but it’s practical change required is minimal, in my case. (The time it took to learn and understand enough to reach this conclusion wasn’t. though…)