Ive got a project Im converting over to CMake. One of the more unusual things that it involves are some custom binary config data objects it creates from object files. In the old make project it would take the .o’s, objcopy them then create a single binary from them using specific offsets and add a CRC.
Im trying to work out how I can do this using CMake without spiralling into a hole of weird complexity. I’ve got as far as figuring out I can use an
add_library(target OBJECT …)
which to begin with seems to get me started. However, next step is running objcopy on each .o in turn to create binary data files.
Initially I tried using add_custom_command() but it appears you can’t use “$<TARGET_OBJECTS:objlib>” as a dependency… As a bodge I’ve running a foreach on the list of sources, using a string regex replace to generate a .o name then adding it as a dependency in add_custom_command()… This seems to work, but now im stuck as I can’t work out how to get the path of the .o file where it was created. in the custom command it seems I can now see “$<TARGET_OBJECTS:objlib>” but it’s a list of all the obj paths, not just the one I want…
Anyone got any ideas on where to go from here? I feel like I might be completely misunderstanding cmake’s design intent… Is it really this hard?