Any way to tell cmake to prioritise a file in compile order?

I have a large project with many, many files.

One file takes a very long time to compile - about 2.5 minutes. I don’t have control over that file because it’s a third party dependency.

The build (across cores) looks like this:

With fewer cores, it’s possible this file starts late in the compile which extends the compile time a lot.

So - is there a nice way in cmake to ask it to compile this file as early as possible?


1 Like

CMake doesn’t have any (and therefore does not provide any) control over this. With that build output, I assume you’re using the Ninja generator. In that case, this issue is of interest.

Ah - thanks Ben!

I went back-and-forth as to whether this would be a cmake or a ninja thing.

I’ll take a look.

In case anyone lands here looking for something similar, I asked the same question over on the ninja repo.

There is an open PR to support this, but it’s old and hasn’t been merged…

Another thing in that PR is pretty cool: on rebuild it uses info from previous builds to adjust the order automatically.