I have done a search for this, yet yielded very few results. I developed a Particle Accelerator Tracking Code using CUDA, under MS Visual Express C++ 2008 and Windows XP. This works fine on my machine, and is ready for release. The project I have is a little messy and just needs the file structure to be moved around a bit so it is more readable. Also, there is a requirement for a Linux version and possibly Mac.
My PhD co-supervisor proposed using the Cross-Platform build system, CMake. I have been trying to use the FindCUDA.cmake script from MIT with limited success. For some reason though, it does not automatically pick up that I have CUDA installed, or that I have a CUDA compatible driver installed. I can define these manually, but it still fails to find the CUDA library prefix and suffix. Has anyone used CUDA with CMake successfully? If so, please could you provide some pointers, and possibly a link to the FindCUDA script you used?
Maybe it helps you looking at another CMakeLists.txt file for some orientation. Note however that I’m new to CMAKE and what I’m doing here might be totally wrong, but it compiles and works for me.
I’m also using the folder structure described in the example project, but I had to manually point the findCuda script to libcuda.so. It can be done manually by using ccmake and showing the advanced options. I’m pretty sure the windows version of CMAKE should other something similar.
EDIT:
I just forgot: The reason the findCuda script might not find your CUDA installation is because it’s looking the directories specified in the file and they were for Linux system only (if I remember correctly).
So you can either edit the paths there or manually set them in CMAKE.
#file goes into the ./source directory
PROJECT( MYPROJECT )
cmake_minimum_required(VERSION 2.4)
# Add current directory to the nvcc include line.
CUDA_INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
#CUDA
/home/linny/NVIDIA_CUDA_SDK/common/inc
/usr/local/cuda/include
/usr/include
)
# C/C++ Compiler Includes
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# more C/C++ Compiler Includes
INCLUDE_DIRECTORIES(
/home/linny/NVIDIA_CUDA_SDK/common/inc
/usr/local/cuda/include
/usr/include/SDL
)
# directories where the linker should check for libs
LINK_DIRECTORIES(/home/linny/NVIDIA_CUDA_SDK/lib)
LINK_DIRECTORIES(/usr/lib)
LINK_DIRECTORIES(/usr/lib64)
##############################################################################
# Use one executable only.
CUDA_ADD_EXECUTABLE(ray
ray.cu
)
#link libSDLxx
TARGET_LINK_LIBRARIES (ray SDL )
#link libcutil
TARGET_LINK_LIBRARIES (ray cutil )
Cheers Linny. I have altered the script to be Win XP friendly and I get a project built. Unfortunately, the CUDA libraries are not being found on compilation. However, your code above gives me some good pointers, just got to work out how that relates to my code.