Hi, I'm trying to use CMake with FindCUDA to compile a C++/CUDA code, and I am having a small issue with cuda_add_executable.
One of my files has the .cc extension, but it may import headers which contain CUDA kernels definitions (depending on wheather I want to use CUDA or not). So, I need to compile it as a CUDA file. You can tell nvcc to ignore the file extension and use a particular language with the -x option. For instance: nvcc -x cu foo.cc Will force to compile foo.cc as a CUDA file. However, I don't know how to pass that compilation option to nvcc through cuda_add_executable. I tried to set it in the CUDA_NVCC_FLAGS variable, but it never gets passed to nvcc, since CMake calls directly the C++ compiler. Can anyone suggest how to force the -x option? PS: One dirty fix is to create a symlink from foo.cc to foo.cu, and compile foo.cu if CUDA is enable, or foo.cc if it is not. CMake works fine with this workaround, but I'd rather pass the -x option and keep my code base clean. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
