title: Swig with CMake not able to find header includes
body: <p>I am trying to run swig using CMake and I am getting </p>
  
  <pre><code>java.i:9: Error: Unable to find 'api.h'
  java.i:10:Error: Unable to find 'TestStruct.h'
  </code></pre>
  
  <p>I have tried setting <code>USE_LIBRARY_INCLUDE_DIRECTORIES</code>, <code>SWIG_USE_TARGET_INCLUDE_DIRECTORIES</code>, <code>SWIG_USE_LIBRARY_INCLUDE_DIRECTORIES</code>, without any luck. I am probably failing to understand something that is going on. My understanding was that I am linking to the <code>api</code> target so those include directories should be visible.</p>
  
  <p>Note: That it works if I copy those headers into the build directory where swig is getting called.</p>
  
  <p><strong>Any information will be helpful. Thanks.</strong></p>
  
  <p><strong>java.i</strong></p>
  
  <pre><code> %module example
   %include "std_string.i"
   %{
   /* Put header files here or function declarations like below */
   #include "api.h"
   extern TestStruct TestFunc();
   %}
  
   %include "api.h"
   %include "TestStruct.h"
   extern TestStruct TestFunc();
  </code></pre>
  
  <p><strong>CMakeLists.txt for the swig target</strong></p>
  
  <pre><code>find_package(SWIG REQUIRED)
  include(${SWIG_USE_FILE})
  
  find_package(Java REQUIRED)
  find_package(JNI REQUIRED)
  
  set_property(SOURCE java.i PROPERTY CPLUSPLUS ON)
  
  swig_add_library(javaExample
    TYPE SHARED
      LANGUAGE java
      SOURCES java.i)
  
  target_include_directories(javaExample PRIVATE ${JNI_INCLUDE_DIRS})
  target_link_libraries(javaExample PRIVATE api)
  </code></pre>
  
  <p><strong>CMakeLists.txt for the api target</strong></p>
  
  <pre><code>add_library( api SHARED 
      inc/api.h
      src/api.cpp
  )
  
  target_include_directories( api
    PUBLIC
      inc
  )
  
  target_link_libraries( api
    PUBLIC
      FooTypes
    PRIVATE
      FooBar
  )
  
  add_subdirectory(src/FooBar)
  
  </code></pre>