title: VS2019 intellinsense issue on cmake project
body: <p>My project is like <a href="https://i.stack.imgur.com/oKCKi.png" rel="nofollow noreferrer">this</a></p>
  <p>I want to use preprocessor definition <code>DLIB</code>(<code>DLib/CMakeLists.txt</code>) to control macro <code>API</code>(<code>DLib/Core.h</code>) in CMake project, it works but VS intellinsense have some problem.</p>
  <pre><code># Issue/CMakeLists.txt
  cmake_minimum_required (VERSION 3.20)
  add_compile_definitions(PLATFORM_WINDOWS)
  project (&quot;Issue&quot;)
  add_subdirectory(DLib)
  add_subdirectory(Main)
  </code></pre>
  <pre class="lang-cpp prettyprint-override"><code># Main/CMakeLists.txt
  add_executable(Main)
  target_sources(Main PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Application.cpp)
  target_link_libraries(Main PRIVATE DLib)
  
  // Main/Application.cpp
  #include &quot;DLib.h&quot;
  
  int main() {
      (new DL::Bar())-&gt;bar();
      return 0;
  }
  </code></pre>
  <pre class="lang-cpp prettyprint-override"><code># DLib/CMakeLists.txt
  add_library(DLib SHARED)
  add_compile_definitions(DLIB)
  file(GLOB_RECURSE SRC *.cpp)
  target_sources (DLib PRIVATE ${SRC})
  target_include_directories(DLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  
  // DLib/DLib.h
  #include &quot;DLib/Core.h&quot;
  #include &quot;DLib/Bar.h&quot;
  
  // DLib/DLib/Core.h
  #ifdef PLATFORM_WINDOWS
      #ifdef DLIB
          #define API __declspec(dllexport)
      #else
          #define API __declspec(dllimport)
      #endif
  #else
      #error Unsupport Platform!
  #endif
  
  // DLib/DLib/Bar.h
  #include &quot;Core.h&quot;
  
  namespace DL {
      class API Bar {
      public:
          void bar();
      };
  }
  
  // DLib/DLib/Bar.cpp
  #include &quot;Bar.h&quot;
  #include &lt;cstdio&gt;
  
  namespace DL {
      void Bar::bar() { printf(&quot;Hello\n&quot;); }
  }
  </code></pre>
  <p>I want to use preprocessor <code>DLL</code> to define <code>API</code>. Above codes are work well.<br />
  But When I use <code>API</code> to decleare class in <code>Foo.h</code> and <code>Baz.h</code>, <code>API</code> macro can not highlight in VS.</p>
  <pre class="lang-cpp prettyprint-override"><code>// Foo.h
  #include &quot;DLib/Core.h&quot;
  
  namespace DL {
      // the API macro can no link to Core.h
      class API Foo {
      public:
          virtual void foo() {}
      };
  }
  
  // Baz.h
  #include &quot;Foo.h&quot;
  
  namespace DL{
      // the API macro can no link to Core.h
      class API Baz : public Foo {
      public:
          void baz() {}
      }
  }
  </code></pre>
  <p>And if I include <code>Foo.h</code> or <code>Baz.h</code> in <code>DLib.h</code>, the intellinsencse is return to normal(I can use <code>ctrl + left click</code> to jump in <code>Core.h</code>).</p>
  <pre class="lang-cpp prettyprint-override"><code>// Core.h
  #include &quot;DLib/Core.h&quot;
  #include &quot;DLib/Bar.h&quot;
  
  // include and regenerate cmake
  // `API` is highlight correctly in Foo.h
  // but Baz.h is wrong still
  #include &quot;DLib/Foo/Foo.h&quot;
  </code></pre>
  <p>When I hover it, VS tip me <code>class DL::API</code> but not <code>#define __declspec(dllexport)</code>(like <code>Bar.h</code>).
  Wheather I include in <code>DLib.h</code>, it can compile and run successful. But it is annoying because I can not get code autocompletions after <code>API</code> class, and I don't want to include that in <code>DLib.h</code>.<br />
  I was just start to using CMake, so maybe CMakeLists have some problem to make it happend.
  VSCode can highlight correctly, but I like use VS more, so I want to fix it.<br />
  English is not my native language, so I may not describe it clearly, and please excuse typing errors.</p>