[vtk-developers] How to write CMakeLists.txt for a library using CUDA?

Moreland, Kenneth kmorel at sandia.gov
Mon Mar 17 13:59:13 EDT 2014

This question is really more applicable to the VTK users list, so I'm responding to there as well.

The short answer is that if you add the command "find_package(CUDA REQUIRED)" to your CMakeLists.txt, that will load the CMake code to find the CUDA install. Then you replace add_library with cuda_add_library. You also have to use a .cu extension for your C or C++ files that use CUDA instead of .c or .cxx or .cpp. The cuda_add_library will only use the requisite nvcc compiler on files with a .cu extension.

For more information, try this command prompt command: "cmake --help-module FindCUDA | less". You can also find several examples on the web.


From: Mingcheng Chen <linyufly at gmail.com<mailto:linyufly at gmail.com>>
Date: Sunday, March 16, 2014 11:36 AM
To: "vtk-developers at vtk.org<mailto:vtk-developers at vtk.org>" <vtk-developers at vtk.org<mailto:vtk-developers at vtk.org>>
Subject: [EXTERNAL] [vtk-developers] How to write CMakeLists.txt for a library using CUDA?

Hi everyone,

Thanks for your time!

I write a class which uses VTK and CUDA, and I want to write a CMakeLists.txt for others to build my library. I only know how to write CMakeLists.txt for executables. Could anybody please show me how to write for a library?


Best regards,
Mingcheng Chen
March 16th, 2014

Research Assistant in Graphics Group
University of Illinois at Urbana-Champaign
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140317/8da85f62/attachment-0002.html>

More information about the vtk-developers mailing list