0

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?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
fskoras
  • 68
  • 7
  • 1
    For context, what does your custom command do? You could possibly (ab)use [the `_COMPILER_LAUNCHER` target property](https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html) to do this, but it currently only supports Makefile and Ninja generators (apparantly you can also [shoehorn XCode support](https://crascit.com/2016/04/09/using-ccache-with-cmake/) though). – starball Sep 23 '22 at 19:55
  • It may seem unnecessary, but please be understanding :). I am trying to run a script which will generate a dependency file from gcc command which I will use to specify include directories for each TU. This list of include directories will later be dumped to a file and fed in to compile command using the @FILE syntax. "my cystom command" runs on a very long list of globally defined include directories retrieved from the Eclipse project. This list is so long that when I try to pass it to gcc with a response file it hits the 32k CreateProcess limit for Windows. – fskoras Sep 24 '22 at 10:23

0 Answers0