[vtkusers] CMake, UseVTK.cmake and CUDA incompatibility

Cory Quammen cory.quammen at kitware.com
Sun Jun 26 05:53:45 EDT 2016

Hi Andreas,

The best way I have found to build a project that uses CUDA and VTK is to:

- make sure the CUDA code is compiled into a separate library target
- clear out the include directories and compiler definitions prior to
specifying the CUDA library target to avoid problems with spaces in
the VTK definitions and too-long command lines
- link you application against the CUDA library and VTK

In your CMakeLists.txt file in the directory for the CUDA library, the
library target set up would look something like this:

# Reset the include directories to avoid an error from the number of
/I -I options
# making the command line for nvcc too long.
set_directory_properties( PROPERTIES INCLUDE_DIRECTORIES "" )

# The definitions (-DFOO) from VTK were confusing nvcc
set_directory_properties( PROPERTIES COMPILE_DEFINITIONS "" )
cuda_add_library( myCUDAlibrary

Hope that helps,

On Sun, Jun 26, 2016 at 11:13 AM, Andreas Hermann <squelsh at gmx.net> wrote:
> Hi everyone,
> I am new to the list, but I already found several postings here that
> describe the same problem. Unfortunately no satisfying answer was given yet
> (AFAIK).
> I am trying to compile a larger project that uses CUDA and PCL (invoking
> VTK).
> But a bunch of CMAKE Flags defined by VTK kill NVCCs parsing, as they
> include spaces.
> Result is:
> "nvcc fatal   : A single input file is required for a non-link phase when an
> outputfile is specified"
> Those flags are not required when calling NVCC but VTK defines them globally
> ):
> Gregory Kramida describes the problem best in his mail from Dec 2015:
> http://public.kitware.com/pipermail/vtkusers/2015-December/093367.html
> So my question is: How do you use CUDA together with VTK in a CMake project?
> It would be great to get any advice on how to handle this...
> Thanks,
> Andreas
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers

Cory Quammen
R&D Engineer
Kitware, Inc.

More information about the vtkusers mailing list