On Sat, May 5, 2012 at 3:32 AM, Ming <span dir="ltr">&lt;<a href="mailto:ymyang@wisc.edu" target="_blank">ymyang@wisc.edu</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div dir="ltr">
<div dir="ltr">
<div style="font-size:10pt;font-family:&#39;Arial&#39;">
<div>
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:&#39;Calibri&#39;;display:inline;font-weight:normal"><i><b>From:</b> 
</i><a title="jamesbigler@gmail.com" href="mailto:jamesbigler@gmail.com" target="_blank"><i>James Bigler</i></a><i> </i></div>
<div style="FONT:10pt tahoma">
<div style="BACKGROUND:#f5f5f5">
<div><i><b>Sent:</b> Saturday, May 05, 2012 1:51 AM</i></div>
<div><i><b>To:</b> </i><a title="ymyang@wisc.edu" href="mailto:ymyang@wisc.edu" target="_blank"><i>Ming</i></a><i> </i></div>
<div><i><b>Cc:</b> </i><a title="cmake@cmake.org" href="mailto:cmake@cmake.org" target="_blank"><i>cmake@cmake.org</i></a><i> </i></div>
<div><i><b>Subject:</b> Re: [CMake] Moving large MSVS projects to 
CUDA</i></div></div></div>
<div><i></i> </div></div>
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:&#39;Calibri&#39;;display:inline;font-weight:normal"><div><div class="h5"><i>On 
Fri, May 4, 2012 at 12:39 PM, Ming <span dir="ltr">&lt;<a href="mailto:ymyang@wisc.edu" target="_blank">ymyang@wisc.edu</a>&gt;</span> 
wrote:<br></i>
<div class="gmail_quote">
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
  <div dir="ltr">
  <div dir="ltr">
  <div style="FONT-FAMILY:&#39;Calibri&#39;;FONT-SIZE:12pt">
  <div><i>Hello CMake community,</i></div>
  <div><i></i> </div>
  <div><i>I have experience using CMake to generate sime cuda-enabled 
  executables (where the cpp’s reside in one folder, etc.).</i></div>
  <div><i>I am attempting to move a large project that utilizes CMake, from 
  just c++ to CUDA enabled c++.  </i></div>
  <div><i></i> </div>
  <div><i>It is a project that generates a large set of libraries (comprising a 
  toolkit), using various cmake scripts.  I have modified the 
  “add_libraries” call to be “cuda_add_libraries”, and changed all of the .cc 
  files to .cu (but with no additional CUDA code).  An approach I thought 
  would be similar to changing a simple program from add_executable to 
  “cuda_add_executable” and renaming the extension to “.cu”</i></div>
  <div><i>My goal was first to have it compile properly in its original form 
  post migration, but am met with some very strange errors in visual 
  studio.  </i></div>
  <div><i></i> </div>
  <div><i>I am wondering if anyone else has undertaken such a migration before 
  (libraries or binaries), and if so, what types of general steps need to be 
  taken other than just telling CMake we’re adding “.cu” files?</i></div>
  <div><i></i> </div>
  <div><i>Thanks all in advance,</i></div>
  <div><i>Ming</i></div></div></div></div><br><i>--<br><br>Powered by </i><a href="http://www.kitware.com" target="_blank"><i>www.kitware.com</i></a><br><br><i>Visit other Kitware 
  open-source projects at </i><a href="http://www.kitware.com/opensource/opensource.html" target="_blank"><i>http://www.kitware.com/opensource/opensource.html</i></a><br><br><i>Please 
  keep messages on-topic and check the CMake FAQ at: </i><a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank"><i>http://www.cmake.org/Wiki/CMake_FAQ</i></a><br><br><i>Follow 
  this link to subscribe/unsubscribe:<br></i><a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank"><i>http://www.cmake.org/mailman/listinfo/cmake</i></a><br></blockquote></div>
<div><br><br><i>What kind of strange errors?<br><br>Typically when adding a new 
CUDA enabled library, you simply start adding the .cu files with the host/device 
code mixed to a cuda_add_* target.<br><br>James<br></i></div>
</div></div><div><font face="Arial">Thank you all for the reply,</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial"><font style="FONT-SIZE:10pt">  -The code in question 
is the Geant4 (<a title="http://geant4.web.cern.ch/geant4/support/download.shtml" href="http://geant4.web.cern.ch/geant4/support/download.shtml" target="_blank">http://geant4.web.cern.ch/geant4/support/download.shtml</a>) 
toolkit, which uses CMake to handle its cross-platform configurations. The end 
result of the toolkit is to compile a large set of 
libraries.</font></font></div>
<div><font face="Arial"><font style="FONT-SIZE:10pt">-I’ve changed all of the 
source files from .cc to .cu, and changed all <i>“add_library” </i>terms to 
</font><i><font style="FONT-SIZE:10pt">“cuda_add_library”</font></i></font></div>
<div><font face="Arial">-I’ve also updated all of the <i>“include 
directories”</i> to <i>“cuda_include_directories”</i></font></div>
<div><font face="Arial">-The end result is that I am able to generate a 
build directory (without any errors) using cmake, for VS2010. </font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial">However when I attempt to build the package in an 
analagous fashion, I get errors from visual studio informing me mid-build that 
it:</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial"><i>Cannot load macro project “ for the following 
reason:</i></font></div>
<div><font face="Arial"><i>C:\...\Projects\VSMacros80\Samples\Samples.vsmacros’ is an 
invalid or inaccessible macro project file</i></font></div>
<div><i><font face="Arial"></font></i> </div>
<div><font face="Arial">Once I acknowledge this message, it then 
says:</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial"><i>CMake has regenerated 3 .sln and/or .vcproj 
files.</i></font></div>
<div><font face="Arial"><i>Click:</i></font></div>
<div><font face="Arial"><i>--Yes to reload the whole 
solution...</i></font></div>
<div><font face="Arial"><i>--No to reload the solution 
...</i></font></div>
<div><font face="Arial"><i>--Cancel to do nothing</i></font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial">This message shows up even though CMake was done 
generating files and was closed prior to the build.</font></div>
<div><font face="Arial">The same thing happens on my work computer, and I 
am able to compile other programs just fine, so I do not believe it to be a 
corrupt install of visual studio.  Any suggestions on why this would occur 
is appreciated!</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial">Thanks,</font></div>
<div><font face="Arial">Ming</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial">Uploaded screenshots of the error 
messages:</font></div>
<div><a href="https://mywebspace.wisc.edu/ymyang/web/macroerr1.png" target="_blank"><font face="Times New Roman">https://mywebspace.wisc.edu/ymyang/web/macroerr1.png</font></a><font face="Times New Roman"> </font></div>
<div><a href="https://mywebspace.wisc.edu/ymyang/web/macroerr2.png" target="_blank"><font face="Times New Roman">https://mywebspace.wisc.edu/ymyang/web/macroerr2.png</font></a><font face="Times New Roman"> </font></div></div>

</div></div></div>
</blockquote></div><br>I believe the macro error is a known problem with the CMake VS macro in VS 2010 (MS broke it).  The regeneration of the project files is also a known behavior of FindCUDA.  The dependencies are computed by nvcc during build and saved in a file.  When the dependency file is regenerated CMake will want to reconfigure to add those new dependencies to the project file.  This is the expected behavior.<br>

<br>My current recommendation for CUDA + VS 2010 is to specify CMAKE_SUPPRESS_REGENERATION OFF in your project file&#39;s CMakeLists.txt:<br>option(CMAKE_SUPPRESS_REGENERATION &quot;Suppress regeneration of build scripts during build&quot; ON)<br>

<br>This will disable the VS CMake plugin, requiring you to manually configure with CMake when you change the build scripts.  I also recommend configuring CMake after your first build to pick up the file level dependencies that CUDA generates.<br>

<br>James<br>