Search code examples
macosboostcmakehomebrew

CMake cannot find Boost on OS X with brew


I'm trying to use CMake to compile another library and it requires Boost.

I have installed both CMake and Boost using brew on OS X 10.10 Yosemite, but CMake refuses to find it. Boost is located in /usr/local/Cellar/boost/1.55.0_2

I've tried the following:

  • Setting -DBoost_DIR and -DBOOST_ROOT with the above path
  • Setting -DBoost_INCLUDE_DIR and -DBOOST_INCLUDEDIR with the above path + /include
  • Setting any and all of these options in the CMakeLists.txt file
  • Compiling Boost myself, and pointing the above vars to my own build
  • Trying out similar solutions to the same problem here, here, and here. The only answer that I found that mentioned brew on OS X was this one, and the same solution did not work for me.

Why is CMake blatantly ignoring my instructions? :(

Edit: CMake output from -DBoost_DEBUG=ON


Solution

  • I found a separate homebrew package of boost-python3. With it installed, CMake does find Boost:

    brew install boost-python3
    

    gives me

    > mkdir build ; ( cd build ; cmake .. )
    -- The C compiler identification is AppleClang 6.0.0.6000056
    -- The CXX compiler identification is AppleClang 6.0.0.6000056
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Found PythonInterp: /usr/local/bin/python (found version "2.7.9")
    -- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.5")
    -- Boost version: 1.56.0
    -- Found the following Boost libraries:
    --   python
    -- Configuring done
    -- Generating done
    

    (I have problems linking, but that's another story)