title: Error C1083 (file not found) with CMAKE target_include_directories
body: <p>I have a c++ project split into a few different libraries/executables in the source tree. There is a top level CMake file that includes some subdirectories. One leaf library B links against another leaf library A. However, even though A has added target_include_directories publicly, in B, I get the error C1083 - cannot open include file.</p>
  <p>OS: Win10</p>
  <p>Using kit GCC 7.3.0:</p>
  <ul>
  <li><p>CMake Command <code>&quot;C:\Program Files\CMake\bin\cmake.EXE&quot; --no-warn-unused-cli -DMOCK_SIMCONNECT:BOOL=TRUE &quot;-DP3D_SDK_ROOT:STRING=C:/Program Files/Lockheed Martin/Prepar3D v4 SDK 4.5.14.34698&quot; -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\Qt\Tools\mingw730_64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\Qt\Tools\mingw730_64\bin\g++.exe -Hd:/repos/cmake_sample_project -Bd:/repos/cmake_sample_project/build -G &quot;MinGW Makefiles&quot;</code></p>
  </li>
  <li><p>Error Message:</p>
  </li>
  </ul>
  <pre><code>[build] D:\repos\cmake_sample_project\src\B\libB.h:5:10: fatal error: libA.h: No such file or directory
  [build]  #include &quot;libA.h&quot;
  [build]           ^~~~~~~~
  [build] compilation terminated.
  </code></pre>
  <p>Using kit Visual Studio Build Tools 2017 Release - amd64:</p>
  <ul>
  <li><p>CMake command: <code>&quot;C:\Program Files\CMake\bin\cmake.EXE&quot; --no-warn-unused-cli -DMOCK_SIMCONNECT:BOOL=TRUE &quot;-DP3D_SDK_ROOT:STRING=C:/Program Files/Lockheed Martin/Prepar3D v4 SDK 4.5.14.34698&quot; -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -Hd:/repos/cmake_sample_project -Bd:/repos/cmake_sample_project/build -G &quot;Visual Studio 15 2017&quot; -T host=x64 -A x64</code></p>
  </li>
  <li><p>Error Message:</p>
  </li>
  </ul>
  <pre><code>d:\repos\cmake_sample_project\src\b\libB.h(5): fatal error C1083: Datei (Include) kann nicht geöffnet werden: &quot;libA.h&quot;: No such file or directory [D:\repos\cmake_sample_project\build\src\B\libB-obj.vcxproj]
  </code></pre>
  <pre><code>sample_cmake_project
  |   CMakeLists.txt
  |   
  +---src
  |   |   CMakeLists.txt
  |   |   
  |   +---A
  |   |   |   CMakeLists.txt
  |   |   |   libA.cpp
  |   |   |   
  |   |   \---public
  |   |           libA.h
  |   |           
  |   \---B
  |           CMakeLists.txt
  |           libB.cpp
  |           libB.h
  |           
  \---tests
          CMakeLists.txt
  </code></pre>
  <p>sample_cmake_project/CMakeLists.txt:</p>
  <pre><code>cmake_minimum_required(VERSION 3.12)
  
  project(sample_project LANGUAGES CXX)
  
  add_subdirectory(src)
  
  enable_testing()
  add_subdirectory(tests)
  </code></pre>
  <p>sample_cmake_project/src/CMakeLists.txt</p>
  <pre><code>add_subdirectory(A)
  add_subdirectory(B)
  </code></pre>
  <p>sample_cmake_project/src/A/CMakeLists.txt</p>
  <pre><code>add_library(libA-obj OBJECT &quot;&quot;)
  
  target_sources(libA-obj 
      PRIVATE
          ${CMAKE_CURRENT_SOURCE_DIR}/libA.cpp
      PUBLIC
          ${CMAKE_CURRENT_SOURCE_DIR}/public/libA.h # &lt;-- header is added as public source.
  )
  
  add_library(libA STATIC $&lt;TARGET_OBJECTS:libA-obj&gt;)
  
  target_include_directories(libA PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/public) # &lt;-- public dir is added to the target's PUBLIC include directories.
  
  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/public)
  </code></pre>
  <p>sample_cmake_project/src/B/CMakeLists.txt:</p>
  <pre><code>add_library(libB-obj OBJECT &quot;&quot;)
  
  target_sources(libB-obj 
      PRIVATE
          ${CMAKE_CURRENT_SOURCE_DIR}/libB.cpp
      PUBLIC
          ${CMAKE_CURRENT_SOURCE_DIR}/libB.h
  )
  
  add_library(libB STATIC $&lt;TARGET_OBJECTS:libA-obj&gt;)
  
  target_link_libraries(libB PRIVATE libA)
  
  include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  </code></pre>
  <p>sample_cmake_project/src/A/public/libA.h:</p>
  <pre><code>#ifndef __LIBA_H
  #define __LIBA_H
  
  #include &lt;iostream&gt;
  
  class A 
  {
      public:
      A() { std::cout &lt;&lt; &quot;hello&quot; &lt;&lt; std::endl; };
      ~A() { std::cout &lt;&lt; &quot;bye bye&quot; &lt;&lt; std::endl; };
  
      void saySomething();
  };
  
  #endif
  </code></pre>
  <p>sample_cmake_project/src/A/libA.cpp:</p>
  <pre><code>#include &quot;libA.h&quot;
  
  void A::saySomething()
  {
      std::cout &lt;&lt; &quot;something...&quot; &lt;&lt; std::endl;
  }
  </code></pre>
  <p>sample_cmake_project/src/B/libB.h:</p>
  <pre><code>#ifndef __LIB_B
  #define __LIB_B
  
  #include &lt;iostream&gt;
  #include &quot;libA.h&quot;
  
  class B
  {
  public:
      B();
      ~B();
  
      void saySomething();
  
  private:
      A _a;
  };
  
  #endif
  </code></pre>
  <p>sample_cmake_project/src/B/libB.cpp:</p>
  <pre><code>#include &quot;libB.h&quot;
  
  B::B() :
      _a(A())
  {
      std::cout &lt;&lt; &quot;Hello from lib B&quot; &lt;&lt; std::endl;
      _a.saySomething();
  }
  </code></pre>
  <p>I feel I might be missing something fundamental, but I thought that by adding sample_cmake_project/A/public to the libA target's include directories, the libA.h header should be available for the libraries that link against libA, e.g. libB?</p>
  <p>any thouhts? thanks in advance.</p>