CUDA Object Linking and CMake

Hi! Right now I am working on a project that uses the object linking capabilities of Cuda 5.0. Since the project is starting to get complex, I wanted to switch to using cmake to compile the code. I wanted to know if this was possible.

I’ve been trying to figure this out on my own, but I haven’t had much luck. I understand that a separate object file needs to be compiled using “nvcc -dlink” and then included with the final compilation since cmake does the final compilation using g++. Not really sure how to make this part happen though.

I’m currently attempting to do this using a toy version of the project which is structured similarly the original project. The toy project consists of a main file ( that calls a kernel function to run on the GPU. In each GPU thread an instance of a user-defined class (TextureFunc) is referenced, where the class exists in a separate folder from the main file. The class consists of a and TextureFunc.h file in that folder. I have been able to get this code to compile using Makefiles.

Here are the CMakeList.txt files I have been working with:

In the project directory (contains src directory):

cmake_minimum_required(VERSION 2.8)
find_package(CUDA REQUIRED)

set(CUDA_NVCC_FLAGS "-arch=sm_20; -rdc=true")

#add subdirectories

In the src directory (contains and TextureFunc directory):

target_link_libraries(TextureMain TextureFunc)
install(TARGETS TextureMain DESTINATION bin)

In TextureFunc directory (contains TextureFunc.h and

cuda_add_library(TextureFunc )

Obviously when I try to use these files, I get a linking error since I haven’t included the separately compiled linking file. I don’t really know how to have this file created using cmake though. Any help would be greatly appreciated.