<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello list,<br><br></div>Normally I use dynamic compilation in all my CMake projects with CUDA. But recently I found about CUFFT callbacks, and in order to use them I'm forced to compile against the cufft_static library, which means that I have to use the separate compilation functionality.<br><br></div>After several attempts, I have got something that resembles close to what I want to do. However the cuda_link_separable_compilation_objects macro is somehow stripping the flags I want to pass to nvcc.<br><br></div>I uploaded a test code in Github (<a href="https://github.com/ovalerio/thrust_fft.git">https://github.com/ovalerio/thrust_fft.git</a>), together with compilation instructions for the command line, and the CMake project file that I'm unable to get right. Interesting bits look as follows:<br><br>set(CUDA_SEPARABLE_COMPILATION ON)<br>cuda_compile(DEVICE_OBJS ${PROJECT_SRC} OPTIONS ${NVCC_OPTS})<br>cuda_compute_separable_compilation_object_file_name(LINK_OBJS thrust_fft ${DEVICE_OBJS})<br>cuda_link_separable_compilation_objects(${LINK_OBJS} thrust_fft ${NVCC_OPTS} ${DEVICE_OBJS} <br>    ${CUDA_LIBRARIES}<br>    ${CUFFT_STATIC_LIBRARY}<br>    ${CULIBOS_LIBRARY}<br>)<br><br></div><div>This lines correspond to the following command line instructions:<br></div><div><br> /usr/local/cuda-6.5/bin/nvcc src/<a href="http://thrust_fft_example.cu">thrust_fft_example.cu</a> -dc -o thrust_fft_example.o -ccbin /usr/bin/gcc-4.6 -m64 -Xcompiler ,\"-g\",\"-L/usr/local/cuda-6.5/lib64\",\"-g\" -gencode=arch=compute_35,code=sm_35 -DNVCC -I/usr/local/cuda-6.5/include<br><br>/usr/local/cuda-6.5/bin/nvcc -gencode=arch=compute_35,code=sm_35 -m64 -ccbin "/usr/bin/gcc-4.6" -dlink thrust_fft_example.o -o thrust_fft_example_link.o<br><br>/usr/bin/c++   -g -L/usr/local/cuda-6.5/lib64   thrust_fft_example.o thrust_fft_example_link.o  -o thrust_fft -rdynamic /usr/local/cuda-6.5/lib64/libcudart.so /usr/local/cuda-6.5/lib64/libcufft_static.a /usr/local/cuda-6.5/lib64/libculibos.a -Wl,-rpath,/usr/local/cuda-6.5/lib64:<br><br></div>From close inspection what is happening is that the second line from above, should instead read as:<br></div><br>/usr/local/cuda-6.5/bin/nvcc -gencode=arch=compute_35,code=sm_35 -m64 -ccbin "/usr/bin/gcc-4.6" -dlink thrust_fft_example.o -o thrust_fft_example_link.o <b>-lcudart -lcufft_static<br></b><br></div>Notice that I have strip all the custom path names added by CMake.<br><br></div>Big kudos to the CMake community and the module maintainers that make our work easier.<br><br></div>Hopefully some of you can help me to figure this out. =)<br><br></div><div>Cheers!<br></div><div>--<br></div>Omar V.M.<br></div>