[CMake] debug/optimized include directories

David Cole david.cole at kitware.com
Mon Nov 7 16:48:51 EST 2011


I think the main use case for saying non-additive would be useful is:

Having several targets in a given directory, most of which simply use
the directory's property value, which contains several include
directories. Now... have one target where you want to restrict the
include_directories to a single directory value.

I'd expect to be able to support that via setting the target property
to the single directory value, and *replace* the list of several which
come from the directory property. (An override, rather than an
addition.)

People who want to add to the list, would use the APPEND mode of
set_property. People who want to replace the value would use
set_property to set the value.

The even more complicated scenario arises when you support this as a
source-file property, too. And the same source file is used in more
than one target...


On Mon, Nov 7, 2011 at 4:13 PM, Robert Dailey <rcdailey at gmail.com> wrote:
> How would it not be additive?
> get_target_property() for INCLUDE_DIRECTORIES would return target includes +
> directory includes (that apply to that target, transitively)
> I don't know if preprocessor definitions follow this but this is the
> behavior I would expect.
>
> ---------
> Robert Dailey
>
>
> On Mon, Nov 7, 2011 at 11:23 AM, Alexander Neundorf
> <a.neundorf-work at gmx.net> wrote:
>>
>> 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
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list