<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>
<div>
<div>This question is really more applicable to the VTK users list, so I'm responding to there as well.</div>
</div>
</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>For more information, try this command prompt command: "cmake --help-module FindCUDA | less". You can also find several examples on the web.</div>
<div><br>
</div>
<div>-Ken</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Mingcheng Chen <<a href="mailto:linyufly@gmail.com">linyufly@gmail.com</a>><br>
<span style="font-weight:bold">Date: </span>Sunday, March 16, 2014 11:36 AM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>" <<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>><br>
<span style="font-weight:bold">Subject: </span>[EXTERNAL] [vtk-developers] How to write CMakeLists.txt for a library using CUDA?<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Hi everyone,
<div><br>
</div>
<div>Thanks for your time!</div>
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>Thanks!</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Mingcheng Chen</div>
<div>March 16th, 2014<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div>Research Assistant in Graphics Group<br>
</div>
<div>University of Illinois at Urbana-Champaign</div>
<div><a href="http://mingchengchen.org" target="_blank">http://mingchengchen.org</a></div>
</div>
</div>
</div>
</div>
</div>
</span>
</body>
</html>