[CMake] FindBoost.cmake updated on the bugtracker

Timenkov Yuri ytimenkov at parallels.com
Fri Mar 28 11:16:50 EDT 2008


On Friday 28 March 2008 18:05:40 Andreas Pakulat wrote:
> On 28.03.08 09:36:06, David Thulson wrote:
> > It would be nice if this could get into 2.6.0.  Boost 1.35 is about to
> > be released:
> >
> > http://lists.boost.org/boost-users/2008/03/34896.php
> >
> > And it at least appears that the latest version in the bug tracker
> > will look for 1.35.  Is that right?
>
> Right, but the hardcoded numbers are just some defaults to look for
>
> > The version included in the CMake
> > 2.6.0 Beta does not recognize Boost 1.35.
>
> It does, read the start of the file, you can add to the list by setting
> a cmake variable before calling find_package.
>
> The sole reason for that is so the module doesn't have to be updated
> each time a new boost version is out as now the user of the module can
> provide additional version numbers as needed.
>
> Andreas
Just FYI:

I wrote own (simplier) FindBoost but more specific to my needs. The main 
feature is this approach relies on standard linux installations (single 
version installed into directory without numbers), but works on our windows 
configurations too.

I used following approach to get boost version:

find_path(BOOST_INCLUDE_DIR boost/version.hpp)

if(BOOST_INCLUDE_DIR)
	file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check_boost.cxx"
		"#include <boost/version.hpp>\n#include <iostream>\nint main(){std::cout << 
BOOST_LIB_VERSION << std::endl; return 0; }\n")
	try_run(BOOST_TEST_RUNS BOOST_TEST_COMPILES
		${CMAKE_BINARY_DIR}
		"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check_boost.cxx"
		CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${BOOST_INCLUDE_DIR}"
		OUTPUT_VARIABLE BOOST_VERSION
		)
	if(BOOST_TEST_COMPILES)
		string(REGEX MATCH "1_3[34]_?[0-9]*" BOOST_VERSION ${BOOST_VERSION})
		message(STATUS "Found Boost version ${BOOST_VERSION}")
	else(BOOST_TEST_COMPILES)
		set(BOOST_VERSION "")
	endif(BOOST_TEST_COMPILES)
endif(BOOST_INCLUDE_DIR)

It may be slower, but provides better encapsulation.


More information about the CMake mailing list