[cmake-developers] [CMake 0015157]: FindCUDA.cmake: separate compilation not working as expected

Mantis Bug Tracker mantis at public.kitware.com
Sun Sep 14 12:39:11 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15157 
====================================================================== 
Reported By:                bchretien
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15157
Category:                   Modules
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2014-09-14 12:39 EDT
Last Modified:              2014-09-14 12:39 EDT
====================================================================== 
Summary:                    FindCUDA.cmake: separate compilation not working as
expected
Description: 
I tried using separate compilation for CUDA with CMake, but I had the issue
described by someone else on Stack Overflow:
https://stackoverflow.com/questions/22540783/nvlink-error-when-linking-cuda-code-against-cuda-static-library-cmake

In the CUDA SDK samples, there's a "simpleSeparateCompilation" sample that uses
a Makefile to build a device static library and link it to the executable. I
tried to adapt it to CMake, but the same CUDA linker error arises.

If this is simply because this should be done some other way, then I guess the
documentation in FindCUDA.cmake should be completed. Else, this may be an error
in the module.

Steps to Reproduce: 
Add the enclosed CMakeLists to
$CUDA_HOME/samples/0_Simple/simpleSeparateCompilation.

$ mkdir /tmp/test && cd /tmp/test
$ cmake $CUDA_HOME/samples/0_Simple/simpleSeparateCompilation
$ make
...
[100%] Building NVCC intermediate link file
CMakeFiles/simpleSeparateCompilation.dir/./simpleSeparateCompilation_intermediate_link.o
nvlink error   : Undefined reference to '_Z13multiplyByTwof' in
'/tmp/test/CMakeFiles/simpleSeparateCompilation.dir//./simpleSeparateCompilation_generated_simpleSeparateCompilation.cu.o'
nvlink error   : Undefined reference to '_Z11divideByTwof' in
'/tmp/test/CMakeFiles/simpleSeparateCompilation.dir//./simpleSeparateCompilation_generated_simpleSeparateCompilation.cu.o'
CMakeFiles/simpleSeparateCompilation.dir/build.make:61: recipe for target
'CMakeFiles/simpleSeparateCompilation.dir/./simpleSeparateCompilation_intermediate_link.o'
failed


Additional Information: 
I tested this on Arch Linux with CUDA 6.5 and CMake 3.0.2.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-09-14 12:39 bchretien      New Issue                                    
2014-09-14 12:39 bchretien      File Added: CMakeLists.txt                    
======================================================================



More information about the cmake-developers mailing list