[CMake] Patch to FindBoost.cmake.
Miguel A. Figueroa-Villanueva
miguelf at ieee.org
Wed Aug 1 03:59:31 EDT 2007
On 8/1/07, Andreas Schneider <mail at cynapses.org> wrote:
> Andreas Pakulat wrote:
> > On 31.07.07 15:11:33, Mike Jackson wrote:
> >> I had my own home grown FindBoost.cmake that I have been using but I wanted to
> >> start using someone elses in the hopes that it would get put into the cmake
> >> distribution.. I was looking at the above FindBoost.cmake and the thing that I
> >> seemed to have noticed was that my app would end up linking against ALL the
> >> boost libraries. I usually only link against 3 of them..
> >
> > I didn't recheck after Andreas Schneider comitted the change, but now
> > you should be able to do
> >
> > target_link_libraries(XMLText ${BOOST_FOO_LIBRARY} ${BOOST_BAR_LIBRARY})
> >
>
> This is documented in at the top of the FindBoost.cmake file now.
>
> http://cmake-modules.googlecode.com/svn/trunk/Modules/Boost/FindBoost.cmake
>
> > instead of Boost_LIBRARIES. Its quite natural IMHO to have
> > Boost_LIBRARIES include all boost libs and individual variables for each
> > lib. And AFAIK thats how CMake Module's are supposed to work (somebody
> > may correct me if I'm wrong here)
Well, I don't think this is how CMake Modules are supposed to work,
but somebody may correct me if I'm wrong ;) This is meant to be a
discussion on cmake modules interface in an attempt to clarify issues
and not a critique on this particular package. As it is I think it is
pretty good.
I think that providing a default to link to all libraries found is ok
if the user doesn't provide any component specification. That is:
find_package(Boost)
In this case, I guess it is reasonable to set Boost_FOUND if at least
one library or the include dir (if there are still parts of boost that
are only header files) is found. Also, setting Boost_LIBRARIES to all
available libs is ok. Then if the user wants some specific libs there
is the Boost_thread_FOUND/Boost_thread_LIBRARY variables.
I believe this is mostly how the current FindBoost.cmake
(http://cmake-modules.googlecode.com/svn/trunk/Modules/Boost/FindBoost.cmake)
works except for the mixed case names and the use of an AND rather
than an OR in the following:
if (BOOST_INCLUDE_DIRS AND BOOST_LIBRARIES)
set(BOOST_FOUND TRUE)
endif (BOOST_INCLUDE_DIRS AND BOOST_LIBRARIES)
Again this is appropriate only if boost has to link with at least one
library to work.
Now, all of that is based on the simple call: find_package(Boost).
However, I would expect that when called like:
find_package(Boost COMPONENTS regex serialization)
then:
- Boost_FOUND: set to TRUE if Boost_regex_FOUND and
Boost_serialization_FOUND are TRUE and Boost_INCLUDE_DIRS is set.
- Boost_LIBRARIES: set to Boost_regex_LIBRARY and Boost_serialization_LIBRARY
Just my thoughts...
--Miguel
More information about the CMake
mailing list