How to execute custom command before each compile command in CMake

Viewed 25

I'm trying to create a CMake script that will 'bind' so to speak "my custom command" action to every compile command.

Example scenario

I have 3 sources:

source1.c
source2.c
main.c

This is what I expect to happen:

"my custom command" -> compile: source1.c ->
"my custom command" -> compile: source2.c ->
"my custom command" -> compile: main.c

I want this custom command to be executed only if particular object file needs rebuilding.

It would be nice if I could also pass compiled 'source path' as an argument to "my custom command" using generated expressions somehow.

Is it possible?

0 Answers
Related