How to prevent fetching content on each cmake? #2
Replies: 2 comments
-
Looks like there are a mechanism to prevent t second fetch based on cmake properties. I am not a big cmake guy - but looks like it does not work that way.
And it gives to me:
every time when I run cmake, |
Beta Was this translation helpful? Give feedback.
-
CMake is already supposed to handle that. We would have to debug this script to find out where the problem is. However, if you need a specific version of boost or need very high level libraries, you can just bypass this cmake module and fetch the transitive dependencies directly (since they are stable in a specific version) or just fetch all boost libraries (that's faster since you're already including all of them). For instance, let's say you just want these modules from boost 1.82: mp11 assert config core static_assert throw_exception pool. Then you can just fetch all of them and skip the process of FetchBoostContent analyzing the dependency graph: set(FUTURES_BOOST_VERSION 1.82.0)
set(FUTURES_BOOST_MODULES mp11 assert config core static_assert throw_exception pool)
set(FUTURES_BOOST_TRANSITIVE_MODULES integer type_traits winapi)
set(FUTURES_BOOST_ALL_MODULES ${FUTURES_BOOST_MODULES} ${FUTURES_BOOST_TRANSITIVE_MODULES})
add_library(boost_headers INTERFACE)
add_library(Boost::headers ALIAS boost_headers)
foreach (MODULE ${FUTURES_BOOST_MODULES})
FetchContent_Declare(
boost_${MODULE}
URL https://github.com/boostorg/${MODULE}/archive/refs/tags/boost-${FUTURES_BOOST_VERSION}.tar.gz)
FetchContent_GetProperties(boost_${MODULE})
if (NOT boost_${MODULE}_POPULATED)
FetchContent_Populate(boost_${MODULE})
endif ()
target_include_directories(boost_headers INTERFACE $<BUILD_INTERFACE:${boost_${MODULE}_SOURCE_DIR}/include>)
endforeach ()
target_include_directories(boost_headers INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) You can find the modules for FUTURES_BOOST_TRANSITIVE_MODULES in https://pdimov.github.io/boostdep-report/boost-1.82.0/module-overview.html. That is the first case. In your case, if you are depending on Boost.Geometry, you are effectively depending on almost all boost libraries: https://alandefreitas.github.io/boostdep_graph/libs/geometry.html. FetchContent_Declare(
boost
URL https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.xz) |
Beta Was this translation helpful? Give feedback.
-
I found this cmake module incredible and easy to use.
That is an example on how I use it in my my small project:
Meanwhile, every time when I type
make
it hands for a while on fetching content from boostorg.Maybe I can wrap
FetchBoostContent_Declare
with some if condition to avoid fetching it in case if it is already fetched?Beta Was this translation helpful? Give feedback.
All reactions