title: CMake link shared library built from object libraries
body: <p>I can't get my cmake project running. It should build a library (Core) and then add this library to a new shared library. The problem is that the resulting library does not seem to link correctly against the executable.</p>
  
  <pre><code>fatal error: JNF_NEAT/body.h: No such file or directory
  </code></pre>
  
  <p><br/></p>
  
  <p>I have a CMake project which is structured as follows:</p>
  
  <pre><code>root
    -&gt; CMakeLists.txt
    -&gt; Core/
       -&gt; CMakeLists.txt
       -&gt; Sources/
    -&gt; Examples/
       -&gt; CMakeLists.txt
       -&gt; Example1/
          -&gt; CMakeLists.txt
          -&gt; Sources/
  </code></pre>
  
  <p><br/></p>
  
  <p>root/CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.2.2)
  project(JNF_NEAT)
  
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/lib)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/examples)
  
  add_subdirectory(Core)
  
  add_library(JNF_NEAT SHARED $&lt;TARGET_OBJECTS:Core&gt;)
  target_link_libraries(JNF_NEAT -lstdc++fs)
  
  add_subdirectory(Examples)
  </code></pre>
  
  <p><br/></p>
  
  <p>root/Core/CMakeLists.txt</p>
  
  <pre><code>file(GLOB SOURCES Sources/*.cpp Sources/*.h)
  add_library(Core OBJECT ${SOURCES})
  </code></pre>
  
  <p><br/></p>
  
  <p>root/Examples/CMakeLists.txt</p>
  
  <pre><code>add_subdirectory(XOR)
  </code></pre>
  
  <p><br/></p>
  
  <p>root/Examples/XOR/CMakeLists.txt</p>
  
  <pre><code>include_directories(../../out/lib)
  
  file(GLOB SOURCES Sources/*.cpp Sources/*.h)
  add_executable(XOR_EXAMPLE ${SOURCES})
  target_link_libraries(XOR_EXAMPLE JNF_NEAT)
  </code></pre>
  
  <p><br/></p>
  
  <p>The entire source code is available <a href="https://github.com/SirRade/JNF_NEAT/tree/d9d32d6dd9319b88520fca4337be3589bd7dba79" rel="nofollow">here</a>.</p>
  
  <p><br/></p>
  
  <h3>Edit #1</h3>
  
  <p>I tried setting <code>target_include_directories(XOR_EXAMPLE BEFORE PUBLIC ../../out/lib)</code> before <code>target_link_libraries</code></p>
  
  <p>I also tried setting <code>include_directories(out/lib)</code> in the outer most CMakeLists.txt</p>
  
  <p><br/></p>
  
  <h3>Edit #2</h3>
  
  <p>On Linux <a href="https://gist.github.com/anonymous/787892013a0e66b423eb7cb7ed7e558e" rel="nofollow">this</a> error occures.</p>