CUDA 5.0, CMake, and Make fail on OSX 10.8.3

I am trying to compile a simple Hello World CUDA using CMake on my Mac OSX 10.8.3.

Call cmake . seems successful. Here is my CMakeList.txt :

 project(HelloWorld) cmake_minimum_required(VERSION 2.8) FIND_PACKAGE(CUDA) CUDA_INCLUDE_DIRECTORIES(/Developer/NVIDIA/CUDA-5.0/samples/common/inc) CUDA_ADD_EXECUTABLE(helloWorld helloWorld.cu) 

... and conclusion:

 -- The C compiler identification is Clang 4.2.0 -- The CXX compiler identification is Clang 4.2.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found CUDA: /Developer/NVIDIA/CUDA-5.0 (found version "5.0") -- Configuring done -- Generating done -- Build files have been written to: /Users/mennny/Documents/UNI/6_Semester/0_PMPP/1_exercises/cuda-hello-world 

But the make call subsequently fails with the error (s):

 [100%] Building NVCC (Device) object CMakeFiles/helloWorld.dir//./helloWorld_generated_helloWorld.cu.o clang: error: unsupported option '-dumpspecs' clang: error: no input files CMake Error at helloWorld_generated_helloWorld.cu.o.cmake:206 (message): Error generating /Users/mennny/Documents/UNI/6_Semester/0_PMPP/1_exercises/cuda-hello-world/CMakeFiles/helloWorld.dir//./helloWorld_generated_helloWorld.cu.o make[2]: *** [CMakeFiles/helloWorld.dir/./helloWorld_generated_helloWorld.cu.o] Error 1 make[1]: *** [CMakeFiles/helloWorld.dir/all] Error 2 make: *** [all] Error 2 

I looked for the errors shown, but could not find enough answers. Any ideas why make fails even though cmake succeeded.

Thank you for your help.

+4
source share
2 answers

The default C compiler in Xcode has changed to CLang in OS X Lion. CLang is not compatible with nvcc, so you need to change the compiler that nvcc uses for non-cuda (host) code. Adding the following to your CMakeList.txt will work:

 if (NOT DEFINED CUDA_HOST_COMPILER AND CMAKE_C_COMPILER_ID STREQUAL "Clang" AND EXISTS /usr/bin/gcc) set(CUDA_HOST_COMPILER /usr/bin/gcc CACHE FILEPATH "Host side compiler used by NVCC") message(STATUS "Setting CMAKE_HOST_COMPILER to /usr/bin/gcc instead of ${CMAKE_C_COMPILER}.") endif() 

Adjust the path to gcc as needed.

+1
source

If you don't want to change your CMakeLists.txt, it works if you set the CXX environment variable to "gcc" (unless you have another GCC in your path before it is in / usr / bin).

CMake will automatically pick it up.

0
source

All Articles