[vtk-developers] backward compatible cmake support for vtk modular

Pat Marion pat.marion at kitware.com
Sat Mar 31 11:26:12 EDT 2012


Ok.  JC's email showed how subdirectories can customize the value of the
VTK_LIBRARIES and VTK_INCLUDE_DIRS variables within a subdirectory.  So, if
my goal is to link against the minimum set of required vtk libraries, and
support modular and non-modular vtk, then, here are two possibilities I can
think of:


# at the top level
find_package(VTK REQUIRED)


# in a subdirectory
include(${VTK_USE_FILE})
if(is_modular)
  set(vtk_deps  vtkFiltersCore)
else()
  set(vtk_deps vtkFiltering)
endif()

target_link_libraries(foo ${vtk_deps})


Or, maybe this is the more precise method:


# in a subdirectory
find_package(VTK COMPONENTS vtkFiltersCore) #note, components argument is
ignored for non-modular vtk
include(${VTK_USE_FILE})

if(NOT is_modular)
  set(VTK_LIBRARIES vtkFiltering)
endif()

target_link_libraries(foo ${VTK_LIBRARIES})



Pat


On Fri, Mar 30, 2012 at 10:40 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> And then use ITK_LIBRARIES.
>
> On Fri, Mar 30, 2012 at 4:57 PM, Jean-Christophe Fillion-Robin
> <jchris.fillionr at kitware.com> wrote:
> > Hi Pat,
> >
> > Within ITK,  you could do the following [1]:
> >
> >   MyProject
> >      |----- LibA   (depends on ITKFoo and ITKBar)
> >      |------LibB  (depends on ITKFoo)
> >
> > Considering your project has two libraries and that these library have
> > different requirement regarding the ITK module they need, you could do:
> >
> > In MyProject/LibA/CMakeLists.txt
> >
> >    find_package(ITK COMPONENTS ITKFoo ITKBar)
> >
> >
> > In MyProject/LibB/CMakeLists.txt
> >
> >    find_package(ITK COMPONENTS ITKFoo)
> >
> > I believe the same should be possible within VTK modular.
> >
> > What I wonder is where the name of components are described / listed.
> >
> > Hth
> > Jc
> >
> > [1]
> >
> http://wiki.slicer.org/slicerWiki/index.php/Documentation/Snapshot/Developers/Overlinking_Underlinking#Reply_from_Brad_King
> > [2]
> http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package
> >
> >
> > On Fri, Mar 30, 2012 at 7:40 PM, Pat Marion <pat.marion at kitware.com>
> wrote:
> >>
> >> I could be wrong, but I thought that using VTK_LIBRARIES would cause
> your
> >> project to link to all vtk libraries, when you may only want to link
> with
> >> specific ones, like vtkFiltering (or vtkFiltersCore for modularized.)
> >>
> >> Also, is there is a cmake flag that can determine whether or not the vtk
> >> in use if modularized or not?  Perhaps just looking at the VTK version
> >> number?
> >>
> >> Pat
> >>
> >>
> >> On Fri, Mar 30, 2012 at 7:28 PM, Bill Lorensen <bill.lorensen at gmail.com
> >
> >> wrote:
> >>>
> >>> I think if you use VTK_LIBRARIES in your target_link_libraries
> >>> everything should be OK. With ITK modular, applications use
> >>> ITK_LIBRARIES without problems for both ITKv3 and ITKv4.
> >>>
> >>> On Fri, Mar 30, 2012 at 4:19 PM, Pat Marion <pat.marion at kitware.com>
> >>> wrote:
> >>> > Hi,
> >>> >
> >>> > It seems fairly straightforward to have a project support vtk 5 and
> vtk
> >>> > 6,
> >>> > but what about cmake code that can support both vtk and vtk modular?
> >>> > Any
> >>> > examples of what that might look like?
> >>> >
> >>> > The reason I ask is... PCL uses VTK on the desktop, but what if I
> want
> >>> > to
> >>> > use VTK+VES  for PCL on mobile.  Then the PCL cmake system should
> know
> >>> > how
> >>> > to use vtk modular, since VES uses vtk modular.
> >>> >
> >>> > Pat
> >>> >
> >>> > _______________________________________________
> >>> > Powered by www.kitware.com
> >>> >
> >>> > Visit other Kitware open-source projects at
> >>> > http://www.kitware.com/opensource/opensource.html
> >>> >
> >>> > Follow this link to subscribe/unsubscribe:
> >>> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Unpaid intern in BillsBasement at noware dot com
> >>
> >>
> >>
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.vtk.org/mailman/listinfo/vtk-developers
> >>
> >>
> >
> >
> >
> > --
> > +1 919 869 8849
> >
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20120331/a94fe304/attachment.html>


More information about the vtk-developers mailing list