How to configure cmake to include Accelerators?

I’m trying to use the vtkm accelerators in my VS2017 project but I’m having difficulty figuring out how to configure cmake…

Background,

  • I built vtk from a git clone of master and include the Accelerators and TBB. This build appears to be good.

  • Downloaded built and tested an example example from the new VTK Examples site

  • Modified the example to include the use of the vtkmExternalFaces class
    #include <vtkmExternalFaces.h>
    auto externalFaces = vtkSmartPointer<vtkmExternalFaces>::New();

Building this caused a missing header error, so I modified the cmake flie and added a new line to find the Accelerators project

find_package(VTK COMPONENTS 
  vtkCommonColor
  vtkCommonCore
  vtkCommonDataModel
  vtkFiltersSources
  vtkInteractionStyle
  vtkRenderingCore
  vtkRenderingFreeType
  vtkRenderingOpenGL2 QUIET
  **VTK::AcceleratorsVTKm**)

cmake complains that it can’t find this package. I’ve tried multiple variations of the module name without success (unsurpringly…)

So - How can I include the Accelerators module in my project using cmake?

Thanks,

Doug

Hi, Douglas, g’day,

That package name is quite odd. It doesn’t seem valid. A module name usually corresponds to the name of any of the *.cmake files found where VTK is installed: <vtk_install_directory>/lib/cmake/vtk-<VTK_version>/Modules.

If I were to try module names, I’d look for them there.

Paulo,

Thanks for this info - but when I look in <vtk_install_directory>/lib/cmake/vtk-<VTK_version> I don’t have a Modules folder…

When I look in <vtk_install_directory>/lib/Relese and Debug I do see the libraries I need- vtkAcceleratorsVTKm-8.90.lib. So I can always configure VS manually.

Any idea why I wouldn’t have a Modules folder? Could it be something to do with how I built vtk?

Doug

Hello, Douglas! When you do a VTK deploy (e.g. make install with GCC or build the INSTALL project in VS’ solution) those *.cmake files were supposed to be there…

Anyway, since the module definition CMake files are not there, find_package() won’t work. But you can try to manually add libraries to link to your program with a target_link_libraries() in your CMakeLists.txt.

If you opt to manually add libraries, you will also likely have to add include directories to your CMakeLists.txt too: target_include_directories() so the compiler can find the respective header files.

The names to be given to COMPONENTS of the find_package call should not be prefixed with vtk or VTK:: when using that latest version of VTK from git. In addition all the names of COMPONENTS must be concurrent, in your case you have QUIET mixed into the list, which will cause the query to fail.

So your call would be:

find_package(VTK COMPONENTS 
  CommonColor
  CommonCore
  CommonDataModel
  FiltersSources
  InteractionStyle
  RenderingCore
  RenderingFreeType
  RenderingOpenGL2 
  AcceleratorsVTKm
  QUIET)

Thanks Paulo,

I suspect I didn’t build the INSTALL project and just copied the files I needed to a convenient location…

I was able to get my project working by configuring the includes and libraries manually - I’ll investigate using the install project and see if that helps.

Most of my work with vtk is done using Python - but I’m slowly moving back to C++ so that I can access the vtkm filters. And I’m not very familiar with cmake either…

I’ll likely start to build the Python bindings from source so that I can access the vtkm accelerators from Python - they are not included in the vtk package from anaconda.

Thanks for the help!!!

Doug

1 Like

Thanks Robert,

Moving QUIET to the end fixed the problem - even keeping the vtk prefixes…

Doug