[CMake] Unity builds (was: Re: [ANNOUNCE] CMake 3.16.0-rc1 is ready for testing)

Paul Smith paul at mad-scientist.net
Sat Oct 12 15:40:46 EDT 2019


On Fri, 2019-10-11 at 10:17 -0400, Kyle Edwards wrote:
> On Fri, Oct 11, 2019 at 1:36 AM Alan W. Irwin
> <
> Alan.W.Irwin1234 at gmail.com
> > wrote:
> > The source files that have COMPILE_OPTIONS, COMPILE_DEFINITIONS,
> > COMPILE_FLAGS, or INCLUDE_DIRECTORIES will also be skipped."
> 
> This is by far the most likely reason. We added this restriction
> because we don't want files that have different COMPILE_FLAGS etc. to
> be lumped together in a unity file. We decided that this was good
> enough as a first past, but the way forward is to intelligently group
> together files that have the same COMPILE_OPTIONS,
> COMPILE_DEFINITIONS, COMPILE_FLAGS, and INCLUDE_DIRECTORIES.

I saw this in the manual, and I interpreted it to mean that if we used
something like set_source_files_properties() or set_property(SOURCE) to
set these properties on specific source files, then those files which
are impacted by this won't be part of unity builds.

That seems quite sensible to me.

However, I don't do that hardly anywhere at all; maybe one or two files
have an extra INCLUDE_DIRECTORIES setting or similar.

Virtually all my properties are set on a per-target basis, so I assumed
they wouldn't be an issue here.

Am I misunderstanding that?

It's also possible that a previous attempt to introduce unity builds to
our setup via cotire is interfering with the new, standardized unity
builds.  I am not too familiar with the details of that but I can try
to look into it.



More information about the CMake mailing list