Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

target_include_directories does not work with CUDA

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

Problem

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.

Solution

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 2.8.12.2, CUDA 6.5 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧