Attempting Cross-Platform Make using cmake Hitting problems

Hello all,

I have successfully created a CUDA project in MS Visual C++ Express 9. Its purpose it to simulate the dynamics of a charged particle in an accelerator.

However, various Linux distributions and Macs are used in this area of study, so it has become necessary to use some form of cross-platform make system. As suggested by my Ph.D supervisor, I am using cmake, and combining this with a FindCUDA.cmake script from MIT. On the whole, this works rather well, with only a few prefixes requiring definition from the user.

Unfortunately, when I compile the project created from the cmake output, I get compile errors. In both my project, and the cmake-produced project, the cl.exe compiler is used, but spits out an error in the CUDA header files for the latter. I include the Build Log for your reference.

Any ideas?

Thank you in advance,

Michael Salt
BuildLog.htm (11.1 KB)

Hi,
I’m curious, what’s in here: C:/GPMAD/CUDA/src/coreGPU.cu(146) ? (This is your code, right?)
Good luck.

Sorry, I forgot to explain that one. Line 146 does not exist. That code only goes as far as line 143.

Also, coreGPU.cu is identical to that used in the project that actually worked. The first project, I took the cppIntegration example and modified that project to accomodate what I needed. Everything worked fine then. I am merely using the exact same files to create a project using cmake.

Which CUDA version are you using? I find that in CUDA 1.1, I need to change the generated file to have an extension of .c for FindCUDA.cmake to work. In CUDA 2.0 beta, it needs to be .cc. I have no idea why, it just works for me. Here are the modifications I made to findCUDA.cmake

# include after "# ENDIF(NOT FOUND_CUDA_NVCC_INCLUDE)"

# set the CUDA version by reading cuda.h

file(READ ${CUDA_INCLUDE}/cuda.h CUDA_H_)

string(REGEX REPLACE ".*define CUDA_VERSION ([0123456789]+).*" "\1" CUDA_VERSION "${CUDA_H_}")

# change MACRO(CUDA_add_custom_commands cuda_target)

    # Add a custom target to generate a cpp file (CUDA 2.0 needs .cc files and CUDA 1.1 needs .c files)

    if (${CUDA_VERSION} GREATER 1999)

        SET(generated_file  "${CMAKE_BINARY_DIR}/src/cuda/${stripped_file}_${cuda_target}_generated.cc")

    else(${CUDA_VERSION} GREATER 1999)

        SET(generated_file  "${CMAKE_BINARY_DIR}/src/cuda/${stripped_file}_${cuda_target}_generated.c")

    endif(${CUDA_VERSION} GREATER 1999)

I think that is all the changes you need. I made several other changes too (fixing pathing issues to allow absolute paths like the rest of CMake), but I don’t think these impact the lines I posted here.

MisterAnderson42, you are indeed a gentleman and a scholar. That is PRECISELY what was causing the problem. Three days I have been looking through build logs and compiler arguements to solve this. Thank you.