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
Tried with: CMake 184.108.40.206, CUDA 6.5 and Ubuntu 14.04
The method to add an include directory to a Qt project depends on how the project was created.
If the project has a
.pro file, then add this line to it:
INCLUDEPATH += "C:\some\include\path"
If you have Qt Creator open with the project, you can find the
.pro file under the project name. Alternatively, you can use any editor to edit this file. Remember to run
qmake after adding the include directory.
If the project has a
.includes file, then just add the path directly to it:
Tried with: Qt 5.2.0 and Windows 7 x64
It is common in many setups to have additional include directories that need to be used during compilation of C, C++ or CUDA code. These can be both global or relative local directories. Adding include directories to all targets or specific targets is easy in CMake.
- The directive to add include directories for all targets being compiled by CMake is
include_directories. For example, add this to
- The directive to add include directories for a particular target being compiled by CMake is
target_include_directories. For example, add this to
CMakeLists.txt to compile the target
Tried with: CMake 2.8.7 and Ubuntu 14.04
Many C/C++ projects may have to use header files that are not placed in the standard include directories. In some projects, the include files of the project itself are placed in one or more separate directories. For all such cases, you need to indicate Eclipse CDT to add these include directories to the compilation. Else your compilation fails with the error that an included header file cannot be found.
To add an include directory to your project in Eclipse CDT:
- Right-click on the project name in Project Explorer, choose Properties > C/C++ Build > Settings
For include directory used by C++ files, choose Cross G++ Compiler > Includes. For C files, choose Cross GCC Compiler > Includes.
In the Include paths section, click the + button and add the include directory. If you want to add multiple include directories, add them separately like this.
Tried with: Eclipse 3.7.2, Eclipse CDT 8.0.2 and Ubuntu 12.04 LTS