title: How can I make a library find Eigen with CMake in macOS?
body: <p>I am trying to compile my project with CMake which includes the Ceres Solver library. I'm using macOS Sierra with Xcode 8.1 dev tools.</p>
  
  <p>I installed the library with Homebrew (brew install ceres-solver). I downloaded and tested the binary manually (<a href="http://ceres-solver.org/building.html#mac-os-x" rel="nofollow">http://ceres-solver.org/building.html#mac-os-x</a>), and that works just fine. But I can't include it in my own project because it can't seem to find Eigen. Here is a complete example:</p>
  
  <p>ceres-test/CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)                                                                                            
  project(CeresTest)                                                                                                             
  find_package(ceres REQUIRED)                                                                                                   
  add_executable(                                                                                                                
    TestCeres                                                                                                                    
    src/test_ceres.cpp                                                                                                           
  )                                                                                                                              
  target_link_libraries(                                                                                                         
    TestCeres                                                                                                                    
    ceres                                                                                                                        
  )
  </code></pre>
  
  <p>ceres-test/src/test_ceres.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include "ceres/ceres.h"
  
  int main(int argc, char** argv) {
    std::cout &lt;&lt; "Works." &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>How I compile it:</p>
  
  <pre><code>mkdir build
  cd build
  cmake ..
  make
  </code></pre>
  
  <p>Full output:</p>
  
  <pre><code>me: ceres-test $ mkdir build
  me: ceres-test $ cd build/
  </code></pre>
  
  <p>cmake</p>
  
  <pre><code>me: build $ cmake ..
  -- The C compiler identification is AppleClang 8.0.0.8000042
  -- The CXX compiler identification is AppleClang 8.0.0.8000042
  -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
  -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found required Ceres dependency: Eigen version 3.2.10 in /usr/local/include/eigen3
  -- Found required Ceres dependency: Glog in /usr/local/include
  -- Found Ceres version: 1.11.0 installed in: /usr/local
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /Users/me/Tests/ceres-test/build
  </code></pre>
  
  <p>make</p>
  
  <pre><code>me: build $ make
  Scanning dependencies of target TestCeres
  [ 50%] Building CXX object CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o
  In file included from /Users/me/Tests/ceres-test/src/test_ceres.cpp:3:
  In file included from /usr/local/include/ceres/ceres.h:37:
  In file included from /usr/local/include/ceres/autodiff_cost_function.h:132:
  In file included from /usr/local/include/ceres/internal/autodiff.h:145:
  /usr/local/include/ceres/jet.h:165:10: fatal error: 'Eigen/Core' file not found
  #include "Eigen/Core"
           ^
  1 error generated.
  make[2]: *** [CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o] Error 1
  make[1]: *** [CMakeFiles/TestCeres.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>I have no idea how to resolve this. None of the solutions I found online helped. CMake seems to be finding the Eigen library just fine, so I'm not sure how to add it in.</p>
  
  <p>On a side note I cannot include "Eigen/Core" directly either, but the tests that I was able to compile do include it and those are fine. I'm not familiar how to deal with these kinds of problems with CMake.</p>
  
  <p><strong>Edit:</strong> I can get it to compile if I include it as "eigen3/Eigen/Core" but I can't change the source code for Ceres.</p>