[CMake] Unity builds (was: Re: [ANNOUNCE] CMake 3.16.0-rc1 is ready for testing)
Alan W. Irwin
Alan.W.Irwin1234 at gmail.com
Fri Oct 11 01:28:26 EDT 2019
On 2019-10-10 18:21-0400 Paul Smith wrote:
> On Thu, 2019-10-10 at 14:57 -0400, Robert Maynard via CMake wrote:
>> * The "UNITY_BUILD" target property was added to tell generators to
>> batch include source files for faster compilation times.
>
> Are there any instructions on how to make this work? I tried this:
>
> cmake -G 'Unix Makefiles' -DCMAKE_UNITY_BUILD=ON .
>
> Then ran "make". The output showed I had just as many output .o files
> as input .cpp files and that make ran one compile command per .cpp
> file.
>
> Is there something else I need to do to enable unity builds in my cmake
> files, than just give the above option? The docs imply that the above
> is all that's needed.
Hi Paul:
I have never tried unity builds, but your question did inspire me to
look at [the unity build
documentation](https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html)
which if you follow the links to other related documentation does imply what
you have done above is correct and should by default group 8
source-code files into a lump to be compiled together. Since you are
not getting that behaviour, I am wondering if one or more of the
documented reasons for skipping unity builds is making a difference in your
case. Those reasons are the following:
"The source files marked by GENERATED will be skipped from unity build. This applies also for the source files marked with SKIP_UNITY_BUILD_INCLUSION.
The source files that have COMPILE_OPTIONS, COMPILE_DEFINITIONS, COMPILE_FLAGS, or INCLUDE_DIRECTORIES will also be skipped."
Good luck, and I hope you will keep the list informed of any further
progress you make with your unity build experiments.
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