[CMake] debug/optimized include directories

Alexander Neundorf a.neundorf-work at gmx.net
Mon Nov 7 12:23:59 EST 2011


On Friday 04 November 2011, David Cole wrote:
> On Wed, Nov 2, 2011 at 8:30 PM, Stephen Kelly <steveire at gmail.com> wrote:
> > David Cole wrote:
> >> On Tue, Nov 1, 2011 at 4:33 PM, Robert Dailey
> >> 
> >> <rcdailey at gmail.com> wrote:
> >>> On Tue, Nov 1, 2011 at 3:32 PM, David Cole
> >>> 
> >>> <david.cole at kitware.com> wrote:
> >>>> Not yet
> >>> 
> >>> Meaning there are plans in the works to add such functionality in the
> >>> near future?
> >>> For now I guess I could actually hard code VS environment variables in
> >>> my include directory strings, such as $(Configuration).
> >> 
> >> There is a feature planned to add per-target include directories (as a
> >> target property). As part of that work, we will probably naturally
> >> also add per-configuration values of that new target property. It is
> >> not yet added as a feature request in the bug tracker, but there are
> >> related ones that I may "borrow" for the purpose. Stay tuned for more
> >> info, but it is not coming in the next week or two. Hopefully, in time
> >> for 2.8.7, but it depends on timing at this point.... so no promises.
> > 
> > Hi David,
> > 
> > I'm interested in this feature. I'd like to get it into CMake 2.8.7.
> > 
> > It came up in the recent thread about how Qt5Config.cmake should work:
> > 
> > http://thread.gmane.org/gmane.comp.lib.qt.project.devel/79/focus=226
> > 
> > You mentioned that there are some side-line relevant bugs in the CMake
> > tracker for this. Could you point me to them? Could you also indicate the
> > approximate location in the code to look to for starting to work on this
> > (cmTarget.cxx?).
> 
> See these bugs (and probably others, too, but these looked like the
> most relevant ones when I searched for "include_directories"...)
> 
>   http://public.kitware.com/Bug/view.php?id=1968
>   http://public.kitware.com/Bug/view.php?id=6269
>   http://public.kitware.com/Bug/view.php?id=6493
>   http://public.kitware.com/Bug/view.php?id=8189
> 
> I think the main thing we want is a new target property named
> "INCLUDE_DIRECTORIES" - There's already a directory property with that
> name; the include_directories command is implemented in terms of that
> directory property. Along with that, we will also want
> per-configuration variants of the property, similar to the many
> existing target properties that have per-config variants.
> 
> If you look at the code, you'll see that use of the existing
> INCLUDE_DIRECTORIES property triggers a call to
> cmMakefile::SetIncludeDirectories, which just saves it in a data
> member for later use. You can grep the code for GetIncludeDirectories
> for callers, or for just IncludeDirectories to see the direct usage in
> cmMakefile.cxx itself.
> 
> The interesting bits here are going to be in deciding how to make
> these per-target include_directories behave. Should they be additive?
> Or should they override the directory-level includes entirely?

I think 
get_target_properties(someVar foo INCLUDE_DIRECTORIES)
should return the full list of include directories used for that target.

This would mean that they are not really additive.

Instead, the INCLUDE_DIRECTORIES target property could be initialized from the 
directory-property INCLUDE_DIRECTORIES.
Then, to add include dirs, use
set_property(TARGET foo  APPEND PROPERTY INCLUDE_DIRECTORIES ${bar_INCLUDES} )

To set (and ignore any directory-level include dirs):
set_property(TARGET foo  PROPERTY INCLUDE_DIRECTORIES ${blub_INCLUDES} )

Alex


More information about the CMake mailing list