[CMake] Not finding boost

Dave Yost Dave at Yost.com
Tue Jun 2 17:46:39 EDT 2015


Here is my solution.

if (DEFINED BOOST_ROOT)
  message (" Using argument BOOST_ROOT ${BOOST_ROOT}")
elseif (DEFINED ENV{BOOST_ROOT})
  message (" Using env var BOOST_ROOT $ENV{BOOST_ROOT}")
  set (BOOST_ROOT $ENV{BOOST_ROOT})
else ()
  message (" Looking in CPATH for include/boost/")
  if (DEFINED ENV{CPATH})
    string (REPLACE ":" ";" cpathList $ENV{CPATH})
    foreach (dir ${cpathList})
      if (EXISTS ${dir}/boost)
        message (" BOOST_ROOT found in CPATH ${dir}/..")
        set (BOOST_ROOT ${dir}/..)
        break ()
      endif ()
    endforeach ()
  endif ()
endif ()


> On 2015-06-01, at 7:43 PM, Dave Yost <Dave at Yost.com> wrote:
> 
> Also, from what I can make of
>    CMake.app/Contents/share/cmake-3.2/Modules/FindBoost.cmake
> findBoost looks in
>    /sw/local/
> which is a path from the old, old Fink package system for OS X. findBoost should also look in
>    /usr/local   (Homebrew and long unix tradition)
>    /opt/local   (MacPorts)
>    /opt/           (linux and others)
> 
>> On 2015-06-01, at 7:18 PM, Dave Yost <Dave at Yost.com <mailto:Dave at Yost.com>> wrote:
>> 
>> 
>>> On 2015-06-01, at 2:28 PM, Dave Yost <Dave at Yost.com <mailto:Dave at Yost.com>> wrote:
>>> 
>>> The boost I want is not in a normal location, but:
>>> Boost's include dir is first in my CPATH.
>>> Boost's lib dir is first in my LD_LIBRARY_PATH.
>>> 
>>> Why doesn't cmake 3.2.2 find it?
>>> 
>>> I'm not being picky about the version.
>> 
>> In other words, why should I have to set BOOST_ROOT? It should be obvious where a boost is, even obvious where the one I want is. What am I missing?
>> 
>> 0 Mon 19:13:25 yost DaveBook ~/p/c++/cmake/findboost/build
>> 243 Z% cat ../CMakeLists.txt
>> cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR)
>> 
>> project(findBoost CXX)
>> 
>> find_package (Boost 
>>               COMPONENTS program_options
>>               REQUIRED)
>> 
>> if (NOT Boost_FOUND)
>>   message (FATAL_ERROR "Could not find boost! ${BOOST_VERSION}")
>> endif ()
>> 
>> message ("  Boost_LIBRARY_DIR_DEBUG is ${Boost_LIBRARY_DIR_DEBUG}")
>> 0 Mon 19:13:34 yost DaveBook ~/p/c++/cmake/findboost/build
>> 244 Z% cmake --version                            
>> cmake version 3.2.20150504-ga4a12
>> 
>> CMake suite maintained and supported by Kitware (kitware.com/cmake <http://kitware.com/cmake>).
>> 0 Mon 19:13:45 yost DaveBook ~/p/c++/cmake/findboost/build
>> 245 Z% ls -l /usr/local/boost/1.55.0..llvm/include
>> total 0
>> drwxrwxr-x  221 yost  admin  7514 Mar  8 22:19 boost
>> 0 Mon 19:13:51 yost DaveBook ~/p/c++/cmake/findboost/build
>> 246 Z% CPATH=/usr/local/boost/1.55.0..llvm/include
>> 0 Mon 19:13:53 yost DaveBook ~/p/c++/cmake/findboost/build
>> 247 Z% ls -l /usr/local/boost/1.55.0..llvm/lib/libboost_program_options.*
>> -rw-rw-r--  1 yost  admin  938312 Mar  8 22:19 /usr/local/boost/1.55.0..llvm/lib/libboost_program_options.a
>> -rwxrwxr-x  1 yost  admin  444236 Mar  8 22:18 /usr/local/boost/1.55.0..llvm/lib/libboost_program_options.dylib
>> 0 Mon 19:14:18 yost DaveBook ~/p/c++/cmake/findboost/build
>> 248 Z% LD_LIBRARY_PATH=/usr/local/boost/1.55.0..llvm/lib 
>> 0 Mon 19:14:22 yost DaveBook ~/p/c++/cmake/findboost/build
>> 249 Z% DYLD_LIBRARY_PATH=/usr/local/boost/1.55.0..llvm/lib
>> 0 Mon 19:14:25 yost DaveBook ~/p/c++/cmake/findboost/build
>> 250 Z% cmake ..                                           
>> CMake Error at /Applications/CMake.app/Contents/share/cmake-3.2/Modules/FindBoost.cmake:1243 (message):
>>   Unable to find the requested Boost libraries.
>> 
>>   Unable to find the Boost header files.  Please set BOOST_ROOT to the root
>>   directory containing Boost or BOOST_INCLUDEDIR to the directory containing
>>   Boost's headers.
>> Call Stack (most recent call first):
>>   CMakeLists.txt:5 (find_package)
>> 
>> 
>> CMake Error at CMakeLists.txt:10 (message):
>>   Could not find boost!
>> 
>> 
>> -- Configuring incomplete, errors occurred!
>> See also "/Users/yost/p/c++/cmake/findboost/build/CMakeFiles/CMakeOutput.log".
>> 1 Mon 19:14:46 yost DaveBook ~/p/c++/cmake/findboost/build
>> 251 Z% 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150602/00f799ab/attachment-0001.html>


More information about the CMake mailing list