CUDA + CMake set_target_properties error

Can someone explain what is the rtt_kernel property in the above code.

I’m getting the following error when I try to configure CMake:

Win 64
CMake Error at CMakeLists.txt:32 (SET_TARGET_PROPERTIES):
set_target_properties Can not find target to add properties to: rtt_kernel

I’m guessing you are trying to copy the code and use it for your own purposes. The code in question is part of a larger system which defined the rtt_kernel target elsewhere.

The error in question comes from trying to set a properly on a target that doesn’t exist. There are several ways to create a target. Here are the most common:

add_executable(<target_name> …)

add_library(<target_name> …)

cuda_add_executable(<target_name> …)

cuda_add_library(<target_name> …)

There’s no really good way to determine what your problem is without seeing your CMakeLists.txt file, but presumably there hasn’t been a call to one of these functions previous to the call to set_target_properties.

If you are trying to adapt your system to use this code, I would suggest you ignore the block of code after the if (WIN32) since this code is attempting to modify the targets for a particular system.

You are correct. I’m trying to use CMake to build Matlab mex files with Cuda. I’m new to CMake and I’m having a lot of difficulties.

Can you point me to a good tutorial or some other resource.

There are a couple of online resources for CMake. Go to the CMake website and click under Help (http://www.cmake.org/ ). The mailing list is particularly good for asking questions on, but if you are just starting out the CMake book is great. The wiki and poking around CMake’s CMakeLists.txt files are also instructive. Any questions directly about the FindCUDA capabilities of CMake can be posted here or on the CMake mailing list (I also monitor that).

Sorry, made a mistake in copying and simplifying stuff

replace rtt_kernel by cuda_mex_kernel and is should work.

i need help, when i use cmake it shows me the following error :
CMake Error at CMakeLists.txt:16 (CUDA_ADD_EXECUTABLE):
Unknown CMake command “CUDA_ADD_EXECUTABLE”.

configuration : cmake 2.6.4, ubuntu 9.10, cuda toolkit 3.2.16
pleas help me.

You probably need to add find_package(CUDA) to your script before you use any cuda_add_* commands. Otherwise those functions won’t exist.

1 Like

@JBigler : Thanks a lot mate! You saved the day/night !!