3

I have a very simple C++ executable and a few .txt resource files. At build time I embedd the .txt files into the C++ binary via linker and then I load them at runtime (based on this answer). That works great.

My problem is relinking. Whenewer I change the .cpp source of my executable and run make, the project rebuilds itself. However, if I change a .txt file and run make, the binary doesn't relink. How can I force CMake to watch changes to my resource files (.txt) so that when those change the executable gets relinked to contain the newest .txt resource files?

Justin
  • 24,288
  • 12
  • 92
  • 142
A Huan
  • 31
  • 1
  • 2
    Can you show some CMake code for this? How are you adding the `.txt` file to the binary? That matters for finding a solution to this – Justin Sep 12 '18 at 21:36

1 Answers1

2

You can set a source property called OBJECT_DEPENDS containing the path to your .txt file. The file to set this property for should be any source that is included in your target.

arrowd
  • 33,231
  • 8
  • 79
  • 110
  • This is the correct answer. Also, make sure to specify full path to the arguments of the `OBJECT_DEPENDS` property to avoid build errors. – arslancharyev31 Sep 19 '21 at 16:25