[cmake-developers] Patch to only consider build dependencies between files in the source directory

Attila Krasznahorkay attila.krasznahorkay at gmail.com
Thu Mar 17 09:54:40 EDT 2016


Hi Brad,

Attached is a new attempt. It seems to work correctly in my tests with the Makefile generator. (Which, to be fair, is the only generator that we use in production mode at the moment...)

Cheers,
            Attila
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-CMAKE_DEPENDS_IN_PROJECT_ONLY-feature-addition.patch
Type: application/octet-stream
Size: 2979 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160317/105974fb/attachment.obj>
-------------- next part --------------


> On 15 Mar 2016, at 19:13, Brad King <brad.king at kitware.com> wrote:
> 
> On 03/15/2016 10:48 AM, Attila Krasznahorkay wrote:
>> https://cmake.org/pipermail/cmake-developers/2015-December/027197.html
>> 
>> With the following patch, when setting the CMAKE_ONLY_IN_SOURCE_DEPENDENCIES
>> variable to 1/ON/TRUE, this file size goes down to just a few kilobytes.
>> Speeding up our build noticeably.
> 
> Thanks.  As Ben pointed out in the original thread the build tree should
> be included as well.  Perhaps a name like
> 
>  CMAKE_DEPENDS_IN_PROJECT_ONLY
> 
> could be used to indicate that it includes only dependencies in the project
> directories (source or build tree).
> 
>> As far as I can see, the "cmake -E cmake_depends" call is only used by
>> the Makefile generator at the moment. So I only taught that generator
>> about this new variable.
> 
> The Makefile generator is the only one for which CMake takes responsibility
> for implicit dependency scanning.
> 
>> I just didn't see what I should do in the Ninja generator for instance
>> to apply this setting. Even though I would be very interested in implementing
>> the feature in that generator as well.
> 
> The Ninja generator uses the compiler's information about dependencies
> as generated by options like `gcc -MD`.  Since that occurs along with
> the compilation there is little cost to including all dependencies
> except for stat during rebuilds.  See discussion here:
> 
>  https://cmake.org/Bug/view.php?id=14914
> 
> about the opposite use case (including system dependencies instead of
> excluding them).
> 
>> +  infoFileStream
>> +    << "set(CMAKE_ONLY_IN_SOURCE_DEPENDENCIES "
>> +    << ( this->Makefile->IsOn( "CMAKE_ONLY_IN_SOURCE_DEPENDENCIES" ) ?
>> +         "1" : "0" )
>> +    << ")\n";
> 
> Rather than communicating this to the dependency scanning step and
> doing the filtering there, please look at applying the filter during
> generation of CMAKE_<LANG>_TARGET_INCLUDE_PATH.
> 
> Thanks,
> -Brad
> 



More information about the cmake-developers mailing list