CMake 3.13 and CUDA

Greetings. It is my understanding that using callable programs might require NVCC option “–relocatable-device-code=true”. Furthermore, “-ptx” NVCC compilation option should also be enabled when compiling Optix based applications.

I’ve been trying to build a visual studio 2017 CUDA project using CMake 3.13. The latest release of CMake has some handy functions for enabling CUDA based visual studio projects (which also conveniently bring up all the CUDA visual studio integration properties in the project properties of generated visual studio projects), i.e. “enable_language(CUDA)”.

Furthermore, CMake also offers two properties: “CUDA_SEPARABLE_COMPILATION” and “CUDA_PTX_COMPILATION”. Both can be set to “ON” and “OFF”. As mentioned above, both needs to be set to “ON”. Sadly, however, they appear to be mutually exclusive, and enabling “CUDA_SEPARABLE_COMPILATION” suppresses “CUDA_PTX_COMPILATION”, automatically setting NVCC compilation type to “–compile”. I was wondering if anyone had experience building Optix projects using latest functionality of CMake (i.e., not resorting to FindCUDA.cmake), and most importantly, successfully enabling both options. I do not want to resort to FindCUDA.cmake because I would really like to have those CUDA properties in my visual studio project.

I am using CUDA 9.2, CMake 3.13 and Visual Studio 2017.