[CMake] Incorrect setting of CUDA_HOST_COMPILER on macosx

James Bigler jamesbigler at gmail.com
Tue Mar 26 21:26:36 EDT 2013


Yes. This was an unforeseen side affect when Mac changed the default compiler mixed with a fix in CMake that changed the default C compiler from gcc to cc (previously you would get clang's CPP compile and gcc's C compiler). 

In general you want CUDA to use the same compiler as the rest of the host code. You can get CUDA to compile with gcc and the rest of your host code compiled with clang, but you can run into compatibility issues. 

I have a fix for this that I've been testing. I just need to push it out to the CMake repository. 

In general for the greatest compatibility you should GCC for the entire tool chain:

env CC=gcc CXX=g++ cmake ..

James

On Mar 26, 2013, at 5:41 PM, Pat Marion <pat.marion at kitware.com> wrote:

> Hi,
> 
> FindCUDA.cmake sets CUDA_HOST_COMPILER to CMAKE_C_COMPILER.  I think that the CUDA_HOST_COMPILER variable was introduced in cmake 2.8.10.  The issue is that on macosx, CMAKE_C_COMPILER defaults to /usr/bin/cc which is clang, and clang is not a supported cuda compiler.  One workaround is to set CUDA_HOST_COMPILER to /usr/bin/gcc on macosx.
> 
> Here is the nvidia documentation that states the requirement "The gcc compiler and toolchain installed using Xcode "
> 
> http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-mac-os-x/
> 
> 
> This bug related to CUDA_HOST_COMPILER shows up on the issue trackers of a few different projects, for example:
> 
> http://code.opencv.org/issues/2504
> http://dev.pointclouds.org/issues/979
> 
> 
> I made a commit for pcl that demonstrates a possible workaround, but I'm interested to have some insight from the cmake community regarding what the best workaround might be.
> 
> https://github.com/patmarion/pcl-1/commit/29a12df7a6218fb3ebdee01c086b21d31d457519
> 
> 
> Thanks!
> Pat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130326/09391466/attachment.htm>


More information about the CMake mailing list