I have two things that I want to do in a CMakeLists.txt file:
- I want to first create an object file that is created by ld (a command like
ld -r -b binary -o binary.o foo.bar
) - Link in this created file into my executable
I looked into using add_custom_target
and/or add_custom_command
, but the CMake documentation has got me confused on how I can actually do both of these tasks effectively from within CMake.
If I add a custom target and specify my own command, how would CMake know which file to link into the executable? If I add a custom command (say PRE_LINK), how can I add it into the linking stage?
Or is there a better way to handling resource files using CMake in Linux?
Thanks in advance.
Edit : Found that this question is essentially the same and answers my question as well: compile and add object file from binary with cmake.