[cmake-developers] FindBoost: boost version vs cached variables

Andriy Gapon avg at icyb.net.ua
Tue Jun 19 10:54:00 EDT 2012


FindBoost.cmake currently (as of CMake 2.8.8) has fairly simply logic to see if
Boost is already found and the relevant variables are cached.
Essentially that logic verifies that Boost_INCLUDE_DIR and
Boost_${COMPONENT}_FOUND variables are set.

What it doesn't do is validate that the found/cached Boost version satisfies the
requested version.  At least it seems so.  And this is amplified by the fact that
the variables remained set and cached even if the original search for Boost
couldn't find a satisfactory version.

A sample CMakeLists.txt file:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(boost_test)
FIND_PACKAGE(Boost 1.51)
IF(Boost_FOUND)
        MESSAGE("Boost 1.51 found!!!")
ELSE(Boost_FOUND)
        MESSAGE("Boost 1.51 not found...")
ENDIF(Boost_FOUND)


As you know, Boost 1.51 doesn't exist yet.

But on a system with Boost 1.48.0 installed I get:

$ cmake .
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is GNU 4.2.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- 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
-- Could NOT find Boost
Boost 1.51 not found...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/avg/tmp/boost-test

So far so good.  Running cmake again:

$ cmake .
Boost 1.51 found!!!
-- Configuring done
-- Generating done
-- Build files have been written to: /home/avg/tmp/boost-test

Adding SET(Boost_DEBUG TRUE) I get the following for a secondary run:
$ cmake .
-- [ /usr/local/share/cmake/Modules/FindBoost.cmake:519 ] boost 1.48.0 is already
in the cache.  To view debugging messages, please clear the cache.
Boost 1.51 found!!!
-- Configuring done
-- Generating done
-- Build files have been written to: /home/avg/tmp/boost-test

So FindBoost correctly knows that it has seen boost 1.48.0, but it misreports that
boost 1.51 is available.

-- 
Andriy Gapon




More information about the cmake-developers mailing list