[CMake] Find correct boost among peers

Johnson, Matt (GE Healthcare) Matthew.Johnson1 at med.ge.com
Mon Feb 8 08:09:43 EST 2016


Scott,

Rather than having the versions fight one another in BOOST_ROOT, you might consider modifying the CMAKE_PREFIX_PATH to include the versions of boost you have - find_package will search there first (you might be able with just giving it the parent of the boost version).  If you set the version and EXACT in the find_package call,  each project should be able to find its version.

You may also want to look at Boost_NO_SYSTEM_PATHS to ensure the FindBoost module isn't hunting around in  places you don't intend.
 
mj

> Date: Mon, 8 Feb 2016 09:46:00 +0100
> From: Petr Kmoch <petr.kmoch at gmail.com>
> To: "B. Scott Harper" <orcein at gmail.com>
> Cc: "cmake at cmake.org" <cmake at cmake.org>
> Subject: Re: [CMake] Find correct boost among peers
> Message-ID:
> 	<CAKohaZcDRMpGtBZyy4v9PXWD5Aowf3Z4CjV0W8PFLQYe5mnXVw
> @mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Hi Scott.
> 
> Regarding the delimiters: you'd see them if you included the dereference in
> the quotes: "Boost root: ${BOOST_ROOT}". When outside quotes, the
> delimiters are effectively swallowed up by message().
> 
> Regarding the main issue: I could be wrong, but from a quick glance at the
> FindBoost.cmake module, it seems to me that it doesn't expect
> BOOST_ROOT to contain more than one path. If it doesn't work for you
> without these hints, you will maybe need to pass them in a different form. I
> cannot suggest one, though; I am not versed enough in the FindBoost
> module.
> 
> Petr
> 
> On Mon, Feb 8, 2016 at 2:10 AM, B. Scott Harper <orcein at gmail.com> wrote:
> 
> > I have several versions of boost downloaded on my machine inside a
> > "thirdparty" directory. Different projects rely on various versions.
> >
> > I am trying to find a later version than the first version in that
> > collection. I have gotten the closest by using a file(GLOB ...) as follows:
> >
> > file(GLOB BOOST_ROOT ${THIRD_PARTY_DIR}/boost_*)
> find_package(Boost
> >   1.60.0
> >   REQUIRED)
> >
> > ...but if I have any versions of Boost earlier than 1.60.0 in this
> > case, it will find only the first directory, recognize that it's too
> > early, and bail out without trying any other directories.
> >
> > When I print out the results of the GLOB action using message(STATUS
> > "Boost root: " ${BOOST_ROOT}), I don't see any delimiters in the
> > string, and I wonder if this it causing the problem? Is this expected
> > beahiour or am I using this incorrectly?
> >
> > Cheers,
> > -- Scott
> >


More information about the CMake mailing list