cmake Add Directories to Compiler Include Path Add a Project's Subdirectory


Example

Given the following project structure

include\
  myHeader.h
src\
  main.cpp
CMakeLists.txt

the following line in the CMakeLists.txt file

include_directories(${PROJECT_SOURCE_DIR}/include)

adds the include directory to the include search path of the compiler for all targets defined in this directory (and all its subdirectories included via add_subdirectory()).

Thus, the file myHeader.h in the project's include subdirectory can be included via #include "myHeader.h" in the main.cpp file.