boost-cmake icon indicating copy to clipboard operation
boost-cmake copied to clipboard

Usage with find_package REQUIRED etc.

Open andrewkcorcoran opened this issue 4 years ago • 1 comments

Some of our existing dependencies use find_package(Boost REQUIRED) or check for the cache variables set by find_package/FindBoost (Boost_INCLUDE_DIR etc.). This seems like it would be quite a common usage. Is there any way to support this usage with boost-cmake?

Note: Even submitting a PR to the dependencies to use modern CMake (target_link_libraries TARGET Boost::thread) won't work as the find_package(Boost COMPONENTS thread REQUIRED) call with cause the configure step to fail unless we manually build the boost components required by the dependency. If we were to do that then we could end up in a weird situation where the dependency is linking to the prebuilt boost library and our library is linking to the boost-cmake boost library. No idea what cmake would do in that situation but it doesn't sound good.

andrewkcorcoran avatar Jan 30 '20 08:01 andrewkcorcoran

Hi,

Same issue here. I was able to make it work with the following code :

add_subdirectory(boost-cmake)
SET (BOOST_ROOT ${CMAKE_CACHEFILE_DIR}/_deps/boost-src)
find_package(Boost 1.71 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS}) 

I hope it helps.

erutovic avatar Feb 21 '20 21:02 erutovic