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

Alan W. Irwin Alan.W.Irwin1234 at gmail.com
Sat Oct 12 22:25:02 EDT 2019


On 2019-10-12 15:40-0400 Paul Smith wrote:

> 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?

I think the current documentation is ambiguous about this.  But
certain target and directory properties can affect the flags used to
compile the source code just as much as source code properties.  So I
am virtually positive the implementation has to pay attention to all
these sources of properties to decide what can/cannot be lumped into a
Unity source file.  If Kyle confirms this guess, then the
documentation should be changed accordingly to remove the ambiguity
about this.

Alan
__________________________
Alan W. Irwin

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.org); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list