[CMake] FindBoost PATH_SUFFIXES fix

Todd Gamblin tgamblin at llnl.gov
Wed Jun 15 12:06:19 EDT 2011


Hi all,

I was somewhat perplexed that FindBoost doesn't properly search the default install layout of the boost-cmake build.  i.e. if you set BOOST_ROOT to point to something that looks like this:

	boost-cmake/
		include/
			boost-1.41.0/
				<boost headers>
		lib/
			boost-1.41.0/
				<boost libraries>

things will break.  This is, unfortunately, the default install layout for the CMake build of boost.  The script only checks path suffixes under the *include* directory, and it expects them to use underscores instead of periods, e.g.:

		include/boost-1_41_0
or		include/boost_1_41_0
or		include/boost-1_41
or		include/boost_1_41

But it doesn't bother checking for something ending in 1.41.0.  Under the lib directory, FindBoost doesn't even bother with path suffixes, and it doesn't know what to do with the above lib directory layout at all.

I've pasted below a patch that adds the version numbers with periods to the list of searched path suffixes, and that uses the path suffix list for both the library search and the header search.  Any objections to my submitting this as a topic branch and pushing it out to next?  I'm not sure I have permission to do that with the FindBoost module, so let me know what the right procedure is.

I'd attach the new FindBoost, but the list won't take messages over 50K.

-Todd

565,588d564
<   # Build a list of path suffixes for each version.
<   set(_boost_PATH_SUFFIXES)
<   foreach(_boost_VER ${_boost_TEST_VERSIONS})
<     # Add in a path suffix, based on the required version, ideally
<     # we could read this from version.hpp, but for that to work we'd
<     # need to know the include dir already
<     set(_boost_BOOSTIFIED_VERSION)
<     
<     # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
<     if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
<       string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" 
<         _boost_BOOSTIFIED_VERSION ${_boost_VER})
<     elseif()
<       string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" 
<         _boost_BOOSTIFIED_VERSION ${_boost_VER})
<     endif()
<     
<     list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_VER}")
<     list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_VER}")
<     list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
<     list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
<   endforeach()
< 
< 
594c570,592
<   IF( NOT Boost_INCLUDE_DIR )      
---
>  IF( NOT Boost_INCLUDE_DIR )
>    # Build a list of path suffixes for each version.
>    SET(_boost_PATH_SUFFIXES)
>    FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
>      # Add in a path suffix, based on the required version, ideally
>      # we could read this from version.hpp, but for that to work we'd
>      # need to know the include dir already
>      set(_boost_BOOSTIFIED_VERSION)
> 
>      # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
>      IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
>          STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" 
>            _boost_BOOSTIFIED_VERSION ${_boost_VER})
>      ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
>          STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" 
>            _boost_BOOSTIFIED_VERSION ${_boost_VER})
>      ENDIF()
> 
>      list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
>      list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
> 
>    ENDFOREACH(_boost_VER)
> 
910d907
<         PATH_SUFFIXES ${_boost_PATH_SUFFIXES}


______________________________________________________________________
Todd Gamblin, tgamblin at llnl.gov, http://people.llnl.gov/gamblin2
CASC @ Lawrence Livermore National Laboratory, Livermore, CA, USA




More information about the CMake mailing list