[vtk-developers] And one include to rule them all

Marcus D. Hanwell marcus.hanwell at kitware.com
Tue Sep 4 14:13:13 EDT 2012


On Tue, Sep 4, 2012 at 11:59 AM, Brad King <brad.king at kitware.com> wrote:
> On 09/01/2012 04:35 PM, David Thompson wrote:
>> We had talked about simplifying the list of include directives VTK 6 passes to the compiler.
>
> Since CMake added support for response files for passing -I
> options to the compiler I wasn't aware of more problems with
> the current approach.  The wrappers use response files too.
>
>>     #include "vtkDataArray.h"
>>
>> would get modified to
>>
>>     #include "Common/Core/vtkDataArray.h"
>
> This approach has at least the following drawbacks:
>
> (1) Authors can accidentally include headers from modules on
> which no dependency has been declared and it will compile.
> We would need to teach HeaderTest to check such dependencies.

True, but they would immediately see the modules being included by
virtue of having typed the path. With the updated approach having
headers not be available is a nice (new) benefit.
>
> (2) It requires changing the install tree layout to duplicate
> the source layout.  This also requires applications to have a
> specific directory in their -I path because headers will not
> be able to include their dependencies from the same directory
> with simple #include "" syntax.

You are saying that the base include path, i.e. /usr/include/vtk-6.0
would be be necessary here? The major advantage in counter to this
would be the simplification of the difference between building against
a build tree or an installed VTK.
>
> (3) Application code will have to be changed to use this style
> also because the headers will have been re-arranged in (2).
> Otherwise they will now need the extensive list of module
> directories in their -I path instead of just the one install
> tree location.
>
For this we can introduce the equivalent of what VTK does when
building against a build tree - adding all depended upon module paths
to the include path of the compiler. This is offered by other projects
such as Qt, where including the use file adds all depended upon
modules to the compiler include path, not including it means
applications must specify QtCore/QDebug etc.

We shouldn't make this change without adding that facility to make
client code easier to write/port. As Berk requested, we will shelve
any changes in this direction until after the 6.0 release anyway.

Marcus



More information about the vtk-developers mailing list