<div dir="ltr">Hi Elvis,<div><br></div><div>The VTK module system was developed to support versions of CMake that didn't support INTERFACE_ properties and all the other nice features of Modern CMake. Now that VTK requires CMake 3.3+ it would be possible to update the module system to provide this support. I believe that other developers are interested in this effort, but I am not aware of an explicit timeline.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 28, 2017 at 11:53 AM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">2017-05-28 17:30 GMT+02:00 Elvis Stansvik <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>><wbr>:<br>
> Hi all,<br>
><br>
> When linking against a VTK module through an imported target, e.g<br>
><br>
>   find_package(VTK 8.0.0 REQUIRED COMPONENTS vtkCommonCore)<br>
>   ...<br>
>   target_link_libraries(myapp vtkCommonCore)<br>
><br>
> I must still manually make sure I use<br>
><br>
>   target_include_directories(<wbr>myapp PUBLIC ${VTK_INCLUDE_DIRS})<br>
>   ...<br>
>   target_compile_definitions(<wbr>myapp PUBLIC ${VTK_DEFINITIONS})<br>
><br>
> to get the include directories and definitions.<br>
><br>
> This is in contrast to e.g. Qt's CMake files, which makes sure targets<br>
> have INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS<br>
> set on its targets. For example, QtSvg (from Qt5SvgConfig.cmake):<br>
><br>
>     set_property(TARGET Qt5::Svg PROPERTY<br>
>       INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Svg_OWN_INCLUDE_DIRS})<br>
>     set_property(TARGET Qt5::Svg PROPERTY<br>
>       INTERFACE_COMPILE_DEFINITIONS QT_SVG_LIB)<br>
><br>
> Now, this is not really a bit inconvenience, I just have to make sure<br>
> to add ${VTK_INCLUDE_DIRS} and ${VTK_DEFINITIONS}.<br>
><br>
> However, I recently started using the libclang-based<br>
> include-what-you-use tool [1] to help sanitize my header inclusions.<br>
> The tool will make suggestions such as (taking a Qt header as example<br>
> here):<br>
><br>
> /home/estan/orexplore/insight/<wbr>src/model/HoleLoader.cpp should add these lines:<br>
> #include <QFileInfo> // for QFileInfo<br>
><br>
> I noticed that for a VTK header, it'll instead suggest e.g:<br>
><br>
> /home/estan/orexplore/insight/<wbr>src/model/Hole.cpp should add these lines:<br>
> #include "vtkSmartPointer.h" // for vtkSmartPointer<br>
><br>
> Notice the "" instead of <>.<br>
><br>
> I dug into include-what-you-use to find out why this is happening, and<br>
> it's because on the compile line, the Qt include directories are given<br>
> with -isystem, while the VTK include directories are given with -I,<br>
> and -isystem vs -I is what the tool uses (for lack of other<br>
> information) to determine whether to suggest the inclusion with <> or<br>
> with "".<br>
><br>
> I believe that maybe the -I flags added for VTK would become -isystem,<br>
> if they were brought in through the INTERFACE_INCLUDE_DIRECTORIES<br>
> mechanism, same as Qt.<br>
><br>
> So all this lead me to two questions regarding VTK:<br>
><br>
> 1. Should VTK's installed CMake files perhaps make sure<br>
> INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_INCLUDE_DEFINITIONS are<br>
> set on its exported targets?<br>
><br>
> 2. If not, anyone know if there's something that could be done to make<br>
> the flags end up as -isystem flags instead of -I when using<br>
> ${VTK_INCLUDE_DIRS}?<br>
<br>
</div></div>Disregard this question: I realized that I could simply use SYSTEM in<br>
my target_include_directories(...<wbr>) to make CMake treat it as a system<br>
include directory, which makes it use -isystem on compilers that<br>
support it.<br>
<br>
So then it's only question 1 left. I think it would be nice to have<br>
INTERFACE_{INCLUDE_<wbr>DIRECTORIES,DEFINITIONS} set on the targets, just<br>
to avoid having to add ${VTK_INCLUDE_DIRS} and ${VTK_DEFINITIONS}<br>
manually.<br>
<span class="HOEnZb"><font color="#888888"><br>
Elvis<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> Cheers,<br>
> Elvis<br>
><br>
> [1] <a href="https://github.com/include-what-you-use/include-what-you-use" rel="noreferrer" target="_blank">https://github.com/include-<wbr>what-you-use/include-what-you-<wbr>use</a><br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtk-<wbr>developers</a><br>
<br>
</div></div></blockquote></div><br></div>