MantisBT - CMake
View Issue Details
0013674CMakeCMakepublic2012-11-09 13:192016-06-10 14:31
James Shackleford 
Kitware Robot 
normalmajoralways
closedmoved 
LinuxUbuntu12.04 LTS
CMake 2.8.10.1 
 
0013674: FindCUDA does not respect -ccbin or --compiler-bindir arguments
FindCUDA/run_nvcc.cmake (lines 106--115) prevent manual specification of the compiler to be used by the Nvidia CUDA compiler nvcc via the -ccbin or --compiler-bindir arguments. The issue is to due the incorrect usage of LIST(FIND ...) to perform a substring search, resulting in a false negative.

As a result of the failed LIST(FIND ...), run_nvcc.cmake sets the preferred compiler to the system default gcc *AND* also passes the undetected manually specified gcc version. This results in nvcc failing due to a duplicate parameter specification for the external compiler.

Because nvcc is only compatible with a select few versions of gcc on Linux, the inability to set this parameter is an issue for users who do not use one of these Nvidia approved versions of gcc as their default compiler.
For example:

  set (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --compiler-bindir=/usr/bin/gcc-4.4")

with result in

   nvcc fatal : redefinition of argument 'compiler-bindir'
I do not believe FindCUDA/run_nvcc.cmake (lines 106--115) are necessary. Removal of these offending lines seems to restore correct behavior for the cases:

[1] -ccbin parameter not specified
[2] -ccbin parameter specified
[3] --compiler-bindir parameter not specified
[4] --compiler-bindir parameter specified
CMake, CUDA, FindCUDA, nvcc
patch FindCUDA.patch (802) 2012-11-09 13:19
https://public.kitware.com/Bug/file/4560/FindCUDA.patch
Issue History
2012-11-09 13:19James ShacklefordNew Issue
2012-11-09 13:19James ShacklefordFile Added: FindCUDA.patch
2012-11-09 13:21James ShacklefordTag Attached: CMake
2012-11-09 13:21James ShacklefordTag Attached: CUDA
2012-11-09 13:22James ShacklefordTag Attached: FindCUDA
2012-11-09 13:22James ShacklefordTag Attached: nvcc
2012-11-11 00:22James BiglerNote Added: 0031522
2013-08-26 15:14domibelNote Added: 0033748
2015-06-04 11:09Michele MastropietroNote Added: 0038884
2016-06-10 14:28Kitware RobotNote Added: 0042147
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0031522)
James Bigler   
2012-11-11 00:22   
What happens when you remove the equal sign?

And by the way CUDA_NVCC_FLAGS is a list and not a string like the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS variables.

You should probably do something like:

list (APPEND CUDA_NVCC_FLAGS --compiler-bindir /usr/bin/gcc-4.4)

I might need to fix up the flag detection to accomodate for using the equal sign, but I want you to be able to make progress as well.

Alternatively with this version of FindCUDA you can now specify the host compiler to use directly:

# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS)
# -- Set the host compiler to be used by nvcc. Ignored if -ccbin or
# --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets
# $(VCInstallDir)/bin is a special value that expands out to the path when
# the command is run from withing VS.
#
(0033748)
domibel   
2013-08-26 15:14   
Removing the equal sign helped in my case.
(0038884)
Michele Mastropietro   
2015-06-04 11:09   
Please see http://stackoverflow.com/questions/30642229/fail-to-build-shared-library-using-cmake-and-cuda [^]

For me the double `--ccbin` option inclusion is resolved with the patch attached.
(0042147)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.