Cmake include_directories()
Quoting the documentation for include_directories
:
The include directories are added to the directory property INCLUDE_DIRECTORIES for the current CMakeLists file. They are also added to the target property INCLUDE_DIRECTORIES for each target in the current CMakeLists file. The target property values are the ones used by the generators.
The INCLUDE_DIRECTORIES
directory property is inherited to all subdirectories and all targets in the directory.
- Specifying
${CMAKE_CURRENT_SOURCE_DIR}
forinclude_directories
is redundant as relative paths are interpreted as relative to this directory by default. You should throw it out to increase readability. - Specifying an include directory in both a subdirectory and its parent is redundant. You should avoid this and settle on one location.
- Use
get_property
andmessage
to double-check that all directories and targets end up with the correct entries in theirINCLUDE_DIRECTORIES
property. - If you are free to require CMake 2.8.11 as a minimum requirement, consider abandoning
include_directories
completely and usetarget_include_directories
instead. This has the advantage that include dependencies get resolved on a per-target basis exclusively which is usually the more desirable behavior.