Reputation: 1
It seems the CMake include_directories will add not only the passed directory but also all its sub directories to the include list. Is there a way to add only one directory (without its sub directories), i.e. some sort on include_directory command?
Upvotes: 0
Views: 349
Reputation: 22023
As indicated in the documentation, only the folders indicated int he command are added, not the subfolders. Of course, if you have a subfolder foo
and someone does #include <foo/bar.h
, then the file will be included.
Consider using target_include_directories
as it is more flexible and better, as it targets one target, and if the target is reused, then dependent includes may also be carried to the dependent targets (depending on PUBLIC
/PRIVATE
/INTERFACE
).
Upvotes: 2