[vtkusers] CMake best practice for using VTK?

Elvis Stansvik elvis.stansvik at orexplore.com
Sat Jul 2 09:23:56 EDT 2016


Den 2 juli 2016 2:45 em skrev "David Gobbi" <david.gobbi at gmail.com>:
>
> On Sat, Jul 2, 2016 at 5:09 AM, Elvis Stansvik <
elvis.stansvik at orexplore.com> wrote:
>>
>>
>> I'm actually a little unsure which set of modules that the script prints
I should be using. It prints three set of modules: referenced, minimal and
maximal. E.g:
>>
>> Modules and their dependencies:
>> find_package(VTK COMPONENTS
>>   vtkCommonColor
>>   vtkCommonComputationalGeometry
>>   vtkCommonCore
>>   vtkCommonDataModel
>>   vtkCommonExecutionModel
>>   vtkCommonMath
>>   vtkCommonMisc
>>   vtkCommonSystem
>>   vtkCommonTransforms
>>   vtkFiltersCore
>>   vtkFiltersGeneral
>>   vtkFiltersSources
>>   vtkGUISupportQt
>>   vtkImagingCore
>>   vtkInteractionStyle
>>   vtkRenderingCore
>>   vtkRenderingOpenGL
>>   vtkkwiml
>> )
>> Your application code includes 18 of 189 vtk modules.
>>
>> All modules referenced in the files:
>> find_package(VTK COMPONENTS
>>   vtkCommonCore
>>   vtkFiltersSources
>>   vtkGUISupportQt
>>   vtkRenderingCore
>>   vtkRenderingOpenGL
>> )
>> Your application code includes 5 of 189 vtk modules.
>>
>> Minimal set of modules:
>> find_package(VTK COMPONENTS
>>   vtkCommonCore
>>   vtkFiltersSources
>>   vtkGUISupportQt
>> )
>> Your application code includes 3 of 189 vtk modules.
>>
>>
>> Would it be enough to use the minimal set? When would I want to use one
of the other two?
>
>
> The minimal set should work.  But I always use the middle set, because I
want to directly link every library that contains a class that I directly
utilize.  If I rely on library dependencies to bring in all the libraries I
use, then I will be out of luck if a future release of VTK manages to
eliminate some of the dependencies I was relying on.

Ah yes, makes sense.

>
> Note that the fact that this list contains an OpenGL/OpenGL2 library
means extra logic is required when building the link line.  I end up with a
mess of cmake code that looks like this:
>
>   # Set VTK_LIBS to the libs I want to link
>   set(VTK_LIBS
>       vtkCommonCore vtkCommonDataModel vtkImagingCore
>       vtkIOImage vtkIOSQL
>       vtkRenderingImage vtkRenderingFreeType)
>   # Conditionally add these libs if present in VTK_LIBRARIES
>   set(VTK_FACTORY_LIBS
>       vtkIOMPIImage vtkIOMySQL
>       vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL
>       vtkRenderingOpenGL2 vtkRenderingFreeTypeOpenGL2)
>   foreach(TMP_LIB ${VTK_FACTORY_LIBS})
>     list(FIND VTK_LIBRARIES ${TMP_LIB} TMP_INDEX)
>     if(TMP_INDEX GREATER -1)
>       set(VTK_LIBS ${VTK_LIBS} ${TMP_LIB})
>     endif()
>   endforeach()

Thanks, I might do this later, but for now I think I want to require the
OpenGL2 backend and thus link against vtkRenderingOpenGL2 unconditionally.

The app will initially run on a computer we provide as part of our product
(analysis machine), so we'll have full control of the environment in which
it runs. But this might change.

Elvis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160702/5b451304/attachment.html>


More information about the vtkusers mailing list