Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building CUDA object files using cmake

Tags:

build

cuda

cmake

I got the following setup. I'm going to extend a framework written in C++ using MPI and other Stuff using CUDA. The Project uses cmake for building. I would like to avoid using a library for my extensions and build object files from my cuda sources. Afterwards I would like to link these object object files and some other files compiled with other compilers. Does anyone have a clue on hwo to achieve that?

I had a look at http://code.google.com/p/cudpp/wiki/BuildingCUDPPwithCMake for getting an overview on how to use CUDA with cmake but this solution uses a library as well.

like image 270
soriak Avatar asked Oct 25 '12 17:10

soriak


1 Answers

It is possible to compile object files with the CUDA support that comes with newer versions of cmake. You use the cuda_compile command. See below.

# CMakeLists.txt for G4CU project                                                                                                                                                                          
project(test-cuda-thrust-gdb)

# required cmake version                                                                                                                                                                                   
cmake_minimum_required(VERSION 2.8)

# packages                                                                                                                                                                                                 
find_package(CUDA)

# nvcc flags                                                                                                                                                                                               
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20)

cuda_compile(HELPER_O helper.cu)
cuda_compile(DRIVER_O driver.cu OPTIONS -G)

cuda_add_executable(driver ${HELPER_O} ${DRIVER_O})

If you need more information have a look at the FindCUDA.cmake file.

like image 141
nwhsvc Avatar answered Nov 13 '22 19:11

nwhsvc