Boost logo

Boost Interest :

Subject: Re: [Boost-cmake] disabling particular external dependencies
From: Sean Chittenden (sean_at_[hidden])
Date: 2009-11-04 20:11:54


> btw, the new cmake boost 1.41 imports look *very* good so far. The
> INSTALL_VERSIONED=ON broke a few things on my first pass, but all
> due to path issues.
>
> I'd ideally like to make use of BOOST_INSTALL_CMAKE_DRIVERS and
> INSTALL_VERSIONED. Is the intention to just include lib/Boost.cmake
> and have it take care of all of the pathing and version information
> depending on the results of find_package(Boost 1.41...) or some
> such? If lib/Boost.cmake can support multiple versions of boost
> installed, it would be *ideal* if the effort required to use boost
> were as simple as:
>
> set(Boost_USE_MULTITHREADED ON)
> set(Boost_MIN_VERSION 1.41)
> set(Boost_SET_INCLUDE ON) # Should default to ON, same concept
> for linker flags
> include("${CONTRIBOBJ}/lib/Boost.cmake")
> find_package(Boost ${Boost_VERSION} COMPONENTS thread NO_MODULE)
> # no need for include(${Boost_INCLUDE_DIR}) with Boost_SET_INCLUDE=ON

Err... 1.41.0 builds smoothly, but I'm having issues integrating
boost with cmake 2.6.4. Looking for "the right way" to do things.

If I'm using a custom installation root, do I use find_package
(Boost...) or include(".../BoostConfig.cmake") ? It's installed in to
the custom root, not just built but uninstalled.

CMakeLists.txt:
> set(WANT_BOOST_VERSION 1.41.0)
> set(Boost_USE_STATIC_LIBS ON)
> set(Boost_USE_MULTITHREADED ON)
> set(Boost_DEBUG TRUE)
>
> find_package(Boost ${WANT_BOOST_VERSION} REQUIRED date_time graph
> program_options regex signals system thread unit_test_framework
> NO_MODULE)
> # include("${CONTRIBOBJ}/share/boost-${WANT_BOOST_VERSION}/cmake/
> BoostConfig.cmake")
> if(Boost_NOTFOUND)
> message(FATAL_ERROR "Boost not found")
> endif()

If you use include() + find_package() you get a bunch of the following
(know it's my fault, but FYI):

Output:
> -- found: Boost
> globbed: ../../boost-1.41.0//cmake//BoostConfig.cmake
> CMake Error at obj/contrib-Darwin-i386/lib/boost-1.41.0/Boost.cmake:
> 16 (ADD_LIBRARY):
> add_library cannot create imported target "boost_date_time-mt-
> static"
> because another target with the same name already exists.
> Call Stack (most recent call first):
> obj/contrib-Darwin-i386/share/boost-1.41.0/cmake/BoostConfig.cmake:
> 28 (include)
> cmake/setup_boost.txt:28 (include)
> cmake/setup_contrib.txt:19 (INCLUDE)
> CMakeLists.txt:16 (INCLUDE)
>
>
> CMake Error at obj/contrib-Darwin-i386/lib/boost-1.41.0/Boost.cmake:
> 19 (ADD_LIBRARY):
> add_library cannot create imported target "boost_date_time-mt-
> shared"
> because another target with the same name already exists.
> Call Stack (most recent call first):
> obj/contrib-Darwin-i386/share/boost-1.41.0/cmake/BoostConfig.cmake:
> 28 (include)
> cmake/setup_boost.txt:28 (include)
> cmake/setup_contrib.txt:19 (INCLUDE)

If I use include(".../BoostConfig.cmake") instead, it obviously
doesn't populate Boost_LIBRARIES because there weren't any COMPONENTS
specified:

> Linking CXX executable ../obj/contrib-Darwin-i386/bin/foo_unittests
> Undefined symbols:
> "boost::test_tools::print_log_value<char const*>::operator()
> (std::basic_ostream<char, std::char_traits<char> >&, char const*)",
> referenced from:
> std::basic_ostream<char, std::char_traits<char> >&
> boost::test_tools::tt_detail::operator<< <char const*>
> (std::basic_ostream<char, std::char_traits<char> >&,
> boost::test_tools::tt_detail::print_helper_t<char const*> const&) in
> foo_unittests.cc.o
> "boost::unit_test::unit_test_log_t::set_checkpoint
> (boost::unit_test::basic_cstring<char const>, unsigned long,
> boost::unit_test::basic_cstring<char const>)", referenced from:
> test_foo::test_method() in foo_unittests.cc.o

I can populate the list of libs that I need by hand, but am looking
for guidance on what's the right way forward.

Is there a correct way to use find_package(Boost...) with an installed
1.41.0 atm? I notice Boost_VERSION is set as a string in
BoostConfig.cmake but the older FindBoost.cmake that comes with cmake
2.6.4 is expecting an integer. -sc

--
Sean Chittenden
sean_at_[hidden]

Boost-cmake list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk