-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add guide for installing/including Boost Histogram standalone (possibly with CMake) #288
Comments
You can look at how boost-histogram in Python works - see https://github.com/scikit-hep/boost-histogram/tree/develop/extern to see what parts of boost are needed. As long as you are CMake and are okay with 3.11+, you can grab these via FetchContent instead of using submodules. |
Thanks @henryiii , I don't intend to make the dependencies as sub-modules, so what I have is more or less in the below: if( ${FOUND_BOOST_HISTOGRAM} )
target_include_directories(${target_name} PUBLIC ${BOOST_HISTOGRAM_INCLUDE_DIR})
if(NOT ${FOUND_BOOST_HISTOGRAM_DEPS})
file(DOWNLOAD
"https://raw.githubusercontent.com/boostorg/cmake/develop/include/BoostFetch.cmake"
"${CMAKE_BINARY_DIR}/BoostFetch.cmake"
)
include("${CMAKE_BINARY_DIR}/BoostFetch.cmake")
boost_fetch(boostorg/cmake TAG develop NO_ADD_SUBDIR)
FetchContent_GetProperties(boostorg_cmake)
list(APPEND CMAKE_MODULE_PATH ${boostorg_cmake_SOURCE_DIR}/include)
foreach(boost_ext assert config core mp11 throw_exception variant2)
boost_fetch(boostorg/${boost_ext} TAG develop EXCLUDE_FROM_ALL)
FetchContent_GetProperties(boostorg_${boost_ext})
target_include_directories(${target_name) PUBLIC ${boostorg_${boost_ext}_SOURCE_DIR}/include)
endforeach(boost_ext)
endif()
endif() which will be put into a separate function/etc... This was mainly put together by following boostorg's histogram CMakeLists.txt. |
Hi @dantrim We should add a guide for this to the docs and add a prominent link to that in the README.md. If you are comfortable with installing boost on your development machine at least and copying the headers of Boost Histogram into your repository, you can compile and use bcp to do that. Be careful though, bcp will also extract the optional dependencies of Histogram by default, which is not what you want (some of these optional dependencies pull in a large part of Boost, e.g. Boost Serialization and Boost Range). You can suppress that by passing the right command-line options to bcp. Long story short, this boils down to placing a copy of all the required headers of Boost Histogram in your project. That's totally fine, but I would recommend to use |
Thanks @HDembinski I think I am happy with my approach -- obviously it is not a copy and paste from what I have in the above (I use a
That would be great! To be honest, I can never get straight the best way to configure and install boost libraries since the boost docs typically leave them out in my experience. I think this is what makes some of my co-workers hesitant when I suggest adding a dependency on boost 👍 If you need a guinea pig to test things out let me know. |
Thank you for the offer, I will come back to you about that. |
I am interested in replacing a
C++
histogram implementation in an existing project withboost/histogram
. This project does not depend onboost
, nor does it necessarily intend to be run on machines that have any part ofboost
installed. For sake of simplicity, I would not like to addboost
as an explicit dependency to this project.Given that
boost/histogram
is "header-only", what is the minimal installation procedure for allowing me to simply drop,at the top of a file and have everything work smoothly. I see that
boost/histogram
has internal dependencies on, e.g.boost/nvp
, so just adding the include path to grabboost/histogram.hpp
once checking out this repository is not sufficient.Is there a minimal working example of dropping in
boost/histogram
as a dependency to an already-existing cmake-based project? The docs are not clear on the installation (apart from assuming the normal perhaps-not-trivial boost installation procedures, I suppose) and I can really only find clear installation guidelines for thepython
bindings viapip
.Thanks!
The text was updated successfully, but these errors were encountered: