MantisBT - CMake
View Issue Details
0016031CMakeCMakepublic2016-03-22 13:092016-06-10 14:21
Thibault Notargiacomo 
 
highmajoralways
closedduplicate 
LinuxAll versions
CMake 3.5 
 
0016031: FindCUDA.cmake - CUDA_SEPARABLE_COMPILATION fails because of escape character
When using
set( CUDA_SEPARABLE_COMPILATION ON )
in cunjunction with
find_package(CUDA 7.5 REQUIRED)

I get a problem in the make command generated for the link with the intermediate object file, especially, the "-ccbin" option that should give to the cuda command line the $CXX variable (in my case).


Try to setup in a directory the following files:

===================================================
test.cu:
#include "test.cu.h"
#include "thrust/device_vector.h"

void A::doIt()
{
    thrust::device_vector<float> a(10,10);
    std::cout <<"A = "<<a[0]<<std::endl;
}

===================================================
test.cu.h:
#include <iostream>

class A
{
public:
    A()=default;
    virtual ~A()=default;
    virtual void doIt();
private:
    int m_a;
};
===================================================
main.cpp:
#include <cstdlib>
#include "test.cu.h"

int main(int argc, char* argv[])
{
    A a;
    a.doIt();
    return EXIT_SUCCESS;
}

===================================================
CMakeLists.txt:
cmake_minimum_required (VERSION 3.5)

ADD_DEFINITIONS( ${CMAKE_CXX_FLAGS} "-std=c++11" )
find_package(CUDA 7.5 REQUIRED)
set( CUDA_SEPARABLE_COMPILATION ON )
cuda_add_executable( testit test.cu main.cpp )
Extract of the build.make file that I had to modify in order to bypass the problem temporarily:

CMakeFiles/testit.dir/testit_intermediate_link.o: CMakeFiles/testit.dir/testit_generated_test.cu.o
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/technic105/Documents/test/cmake35Bug/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building NVCC intermediate link file CMakeFiles/testit.dir/testit_intermediate_link.o"
    /usr/local/cuda/bin/nvcc -m64 -ccbin \"/opt/rh/devtoolset-2/root/usr/bin/gcc\" -dlink /home/technic105/Documents/test/cmake35Bug/CMakeFiles/testit.dir//./testit_generated_test.cu.o -o /home/technic105/Documents/test/cmake35Bug/CMakeFiles/testit.dir/./testit_intermediate_link.o


Notice the -ccbin \"/opt/rh/devtoolset-2/root/usr/bin/gcc\" that causes the build to fail on my machine
No tags attached.
duplicate of 0016027closed Brad King nvcc encloses -ccbin argument with gratuitous quotation marks during intermediate-link phase 
txt CMakeLists.txt (205) 2016-03-22 13:11
https://public.kitware.com/Bug/file/5654/CMakeLists.txt
cpp main.cpp (118) 2016-03-22 13:11
https://public.kitware.com/Bug/file/5655/main.cpp
? test.cu (155) 2016-03-22 13:11
https://public.kitware.com/Bug/file/5656/test.cu
? test.cu.h (120) 2016-03-22 13:12
https://public.kitware.com/Bug/file/5657/test.cu.h
Issue History
2016-03-22 13:09Thibault NotargiacomoNew Issue
2016-03-22 13:11Thibault NotargiacomoFile Added: CMakeLists.txt
2016-03-22 13:11Thibault NotargiacomoFile Added: main.cpp
2016-03-22 13:11Thibault NotargiacomoFile Added: test.cu
2016-03-22 13:12Thibault NotargiacomoFile Added: test.cu.h
2016-03-22 13:13Thibault NotargiacomoNote Added: 0040750
2016-03-22 13:35Brad KingRelationship addedduplicate of 0016027
2016-03-22 13:35Brad KingStatusnew => resolved
2016-03-22 13:35Brad KingResolutionopen => duplicate
2016-06-10 14:21Kitware RobotNote Added: 0041217
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040750)
Thibault Notargiacomo   
2016-03-22 13:13   
I forgot to say that, in order to reproduce the problem, you should run the following commands:

cmake -G "Unix Makefiles"
make
(0041217)
Kitware Robot   
2016-06-10 14:21   
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.