View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013824CMakeModulespublic2012-12-31 03:412013-01-31 10:31
ReporterMathieu Malaterre 
Assigned ToJames Bigler 
PrioritynormalSeverityblockReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0013824: FindCUDA: requires cmake project to have C++ toolchain
DescriptionI cannot use FindCUDA from a C-only cmake project.
Steps To Reproduce$ cd /tmp
$ mkdir cuda
$ cd cuda
$ touch empty.c
$ cat CMakeLists.txt
project(bla C)
include(FindCUDA)
CUDA_ADD_LIBRARY(foo SHARED empty.c)
$ cmake .
[...]
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_CREATE_SHARED_LIBRARY
-- Generating done
-- Build files have been written to: /tmp/cuda
TagsNo tags attached.
Attached Fileslog file icon cuda.trace.log [^] (197,875 bytes) 2013-01-03 13:00

 Relationships

  Notes
(0031962)
James Bigler (developer)
2013-01-03 11:40

CUDA compiles all the host code with the C++ compiler as of version 3.0.

I tried to reproduce this on my Mac with two different versions of CMake and I wasn't able to reproduce your error:

[189] build $ /Applications/CMake\ 2.8-10.app/Contents/bin/cmake ..
-- The C compiler identification is Clang 4.0.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
-- Found CUDA: /usr/local/cuda (found version "5.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jbigler/code/temp/cmake/findcuda-c/build

[192] build $ /Applications/CMake\ 2.8-10.app/Contents/bin/cmake --version
cmake version 2.8.10.2


[184] build $ cmake ..
-- The C compiler identification is GNU 4.2.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Found CUDA: /usr/local/cuda (found version "5.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jbigler/code/temp/cmake/findcuda-c/build

[185] build $ cmake --version
cmake version 2.8.9
(0031963)
Mathieu Malaterre (developer)
2013-01-03 12:58

Hum...I guess this is linux specific. Here is what I get from my VM (debian squeeze + backports):

$ /tmp/cmake-2.8.10.2-Linux-i386/bin/cmake --trace ..
[...]
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1051): get_directory_property(CUDA_NVCC_DEFINITIONS COMPILE_DEFINITIONS )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1052): if(CUDA_NVCC_DEFINITIONS )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1058): if(_cuda_build_shared_libs )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1059): list(APPEND nvcc_flags -Dfoo_EXPORTS )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1063): set(_cuda_wrap_generated_files )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1067): foreach(file empty.c;SHARED;OPTIONS )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1069): get_source_file_property(_is_header ${file} HEADER_FILE_ONLY )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1070): if(${file} MATCHES .*\\.cu$ AND NOT _is_header )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1069): get_source_file_property(_is_header ${file} HEADER_FILE_ONLY )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1070): if(${file} MATCHES .*\\.cu$ AND NOT _is_header )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1069): get_source_file_property(_is_header ${file} HEADER_FILE_ONLY )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1070): if(${file} MATCHES .*\\.cu$ AND NOT _is_header )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1244): set(_generated_files ${_cuda_wrap_generated_files} )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1266): add_library(foo ${_cmake_options} ${_generated_files} ${_sources} )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1271): target_link_libraries(foo ${CUDA_LIBRARIES} )
/tmp/cmake-2.8.10.2-Linux-i386/share/cmake-2.8/Modules/FindCUDA.cmake(1277): set_target_properties(foo PROPERTIES LINKER_LANGUAGE ${CUDA_C_OR_CXX} )
CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present. A line of code such as

    cmake_minimum_required(VERSION 2.8)

  should be added at the top of the file. The version specified may be lower
  if you wish to support older CMake versions for this project. For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_CREATE_SHARED_LIBRARY
-- Generating done
-- Build files have been written to: /tmp/cuda/bin



Let me know if you need anything else
(0031964)
Mathieu Malaterre (developer)
2013-01-03 13:02

In case this is not clear the full log is attached as separate file (cude.trace.log). Thanks.
(0031970)
James Bigler (developer)
2013-01-04 02:07

Out of curiosity, can you set the LINKER_LANGUAGE to C after you call cuda_add_library:

cuda_add_library(foo SHARED empty.c)
set_target_properties(foo PROPERTIES LINKER_LANGUAGE C )
(0031971)
Mathieu Malaterre (developer)
2013-01-04 02:47

Nice ! That works for me. Thanks.
(0032184)
James Bigler (developer)
2013-01-31 10:31

User was able to achieve desired results without changes to FindCUDA.

 Issue History
Date Modified Username Field Change
2012-12-31 03:41 Mathieu Malaterre New Issue
2013-01-02 09:30 Brad King Assigned To => James Bigler
2013-01-02 09:30 Brad King Status new => assigned
2013-01-03 11:40 James Bigler Note Added: 0031962
2013-01-03 12:58 Mathieu Malaterre Note Added: 0031963
2013-01-03 13:00 Mathieu Malaterre File Added: cuda.trace.log
2013-01-03 13:02 Mathieu Malaterre Note Added: 0031964
2013-01-04 02:07 James Bigler Note Added: 0031970
2013-01-04 02:47 Mathieu Malaterre Note Added: 0031971
2013-01-31 10:31 James Bigler Note Added: 0032184
2013-01-31 10:31 James Bigler Status assigned => closed
2013-01-31 10:31 James Bigler Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team