Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

target_include_directories does not work with CUDA

📅 2015-Mar-26 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake, cuda, include directory, nvcc ⬩ 📚 Archive


target_include_directories is an useful CMake directive to specify the include directories for building a particular target, as described here. The FindCUDA module for CMake which handles CUDA compilation seems to completely ignore this directive. The include directories specified for the target are not passed to CUDA compilation by nvcc.

This will most commonly result in errors of the form: someheader.h: No such file or directory.


This is a well known limitation of the CUDA module of CMake, as documented here. There seems to be no plan currently to support target_include_directories for CUDA compilation.

The only solution is to switch to include_directories to add these directories for all the targets in the CMakeLists.txt file.

Tried with: CMake, CUDA 6.5 and Ubuntu 14.04