I have a quite large CMake-based project and found that while generating solution for Visual Studio on Windows I got current project home directory as an include directory. E.g. here's content of root directory:
- A
- impl
- source.cpp
- header.h
- CMakeLists.txt
- B
- CMakeLists.txt
In source.cpp
I accidentally wrote #include "header.h"
instead of #include <A/header.h>
. And such solution was successfully compiled since the directory A
for some reason was added to the list called "Additional Include Directories" in Visual Studio project (i.e. in command-line added as one more /I
option).
Same source slice gives error on Linux build similar to header.h not found
(and it's expected behavior).
Which steps should I take to find the source why does CMake adds target A's root directory to the list of include_directories
. I used the answer to print a list of project related include directories. CMake version is 3.27.1.