Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force CMake to relink project on resources change?

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?

like image 920
A Huan Avatar asked Oct 29 '25 12:10

A Huan


1 Answers

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.

like image 135
arrowd Avatar answered Oct 31 '25 13:10

arrowd