Hard time understanding depencies/action mechanism

Hi All,

New to cmake, trying to migrate a big project from make to cmake.

At the moment I try to understand how dependencies works.

I posted this on stackoverflow with very few views and no valid answers, may be posting here will bring more luck :slight_smile:

In the stko post I used a basic example where I use ld -r on purpose as a tool that build 1 file based on a set of input files. Very often cmake post ask why not using add_lib() add_exe() etc, this is because I try to understand dep/act mechanism to run my tools on set of input (lex, yacc for instance but not limited to)

In my example in stackoverflow post, I can build successfully the initial build but can not touch 1 .c file and rebuild whatโ€™s need to be rebuild. Hope one can help me.


Applying this diff to your example project should solve your issue:

@@ -10,6 +10,7 @@
 COMMAND rm -f l.a
 COMMAND ar r l.a l.o
 COMMAND rm -f l.o

This is basically what Tsyvarev proposed on Stack Overflow, but taking into account that the DEPENDS argument of add_custom_command works with files that live in either the source tree and the binary tree, so you need to give an absolute path.

Thax Alain, I applied this changes and various typos on SO, and we have now a running example.

Iโ€™m back on business :grinning: