[cmake-developers] Printing the origin of include dirs

Stephen Kelly steveire at gmail.com
Thu Dec 20 06:59:08 EST 2012


Brad King wrote:

> On 12/19/2012 09:49 AM, Stephen Kelly wrote:
>> The problem is that in this code:
>> 
>>  include_directories(foo/bar)
>>  add_library(the_lib ...)
>> 
>> the INCLUDE_DIRECTORIES target property is seeded by the directory
>> property of the same name. The backtrace then leads to the add_library
>> invokation instead of the include_directories invokation.
>> 
>> The fix is to modify the management of INCLUDE_DIRECTORIES in cmMakefile
>> to be based on std::vector<cmMakefile::IncludeDirectoriesEntry>, where:
>> 
>>  struct IncludeDirectoriesEntry
>>  {
>>     std::string Value;
>>     cmListFileBacktrace Backtrace;
>>  };
>> 
>> and then use *that* backtrace (and some new API on cmTarget) in
>> cmTarget::SetMakefile, instead of
>> 
>>   this->SetProperty("INCLUDE_DIRECTORIES",
>>                     this->Makefile->GetProperty("INCLUDE_DIRECTORIES"));
>> 
>> Are you ok with that?
> 
> Yes, but this is where having some more smarts inside cmProperty
> could help.  If the value itself knew where it came from then this
> information could be propagated when the value is copied into
> another property.

Ok, I've force-pushed the include-dirs-debugging branch to my clone. Let me 
know if I can merge that to next.

The issue of 'interning' strings in cmListFileBacktrace is complex, so I'll 
defer that optimization for now.

Thanks,

Steve.





More information about the cmake-developers mailing list