How to compile CUDA C files and Nvidia OptiX files inside the same Visual Studio project

I have a running OpTiX (v. 3.0.0) project running on MS Visual Studio Ultimate 2012 and I want to post process some data using C CUDA kernels (v. 5.5).

I can not find information on how to reconfigure the original OpTiX project such that it recognizes and launches the CUDA kernels. The ocean sample in the OptIX SDK does not seem to help since it uses the CuFFT library.

In particular I want to add the following example code in my project:

/***************/
// CUDA runtime
#include <cuda_runtime.h>

// test for CUDA within holorenderer
global void propagate_kernel(float *OPL_L) {
return;
}

host void propagate (float OPL_L) {
// launch the kernel
propagate_kernel<<<128,512>>>(OPL_L);
}
/
**************/

If I add it as a .c file MSVS returns the following compile time error:
error C2059: syntax error : ‘<’ propagation.c
which indicates that the C compiler does not recognize the CUDA kernel launch operator

If I add it as a .cu file MSVS returns the following linker error:
error LNK2019: unresolved external symbol _propagate referenced in function …
which seems to indicate that the resulting file is not being linked in . This is expected since OpTiX loads the ptx files in runtime…

Any example on how to configure this project?
I saw in stackoverflow.com a reference to a similar question in:

http://forums.developer.nvidia.com/devforum/discussion/6656/compile-c-cuda-and-optix-kernels-in-the-same-visual-studio-project

but I do not manage to access this link.

Did you try to use CMake to configure the project?
The OptiX SDK uses it and you can adapt its CMake setup for your project.

BTW: OptiX currently only supports CUDA up to version 5.0:

If you are using CMake to configure your build, take a look at the ocean or collision samples in the SDK. Here you can set a per file property to mark a given CUDA C file for runtime use.

# Tag interop_native_CUDA.cu for OBJ format intead of PTX (which is the default for
  # OPTIX_add_test_executable).  Do this before calling OPTIX_add_test_executable.
  set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/collision_CUDA.cu
    PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ
  )

If you are using the CUDA Toolkit VS build rule, then you need to make sure that you select the correct value for “NVCC Compilation Type” in the GUI configuration. Make sure it is ‘-c/–compile’ instead of ‘-ptx’.