openvdb
openvdb copied to clipboard
[REQUEST] Link against specific Boost libraries rather than Boost::headers and Boost::boost
Is your feature request related to a problem? Please describe.
Currently, OpenVDB links against Boost::headers. This works because when boost is installed it puts all headers in the same folder and Boost::headers
is just an interface target with target_include_directories
set to that folder. If boost is used as a subdirectory Boost::headers
is not created, moreover, different boost libraries are in different folders, thus even if Boost::headers
was defined it would have more than 150 include directories (this issue is discussed here). This makes it hard to use Boost without installing it (e.g. using CMake FetchContent to get the dependency). Which also makes it hard to get started with OpenVDB.
Describe the solution you'd like
Link to the specific targets OpenVDB uses instead of linking to Boost::headers. To my knowledge, OpenVDB uses Boost::numeric_conversion
and Boost::interprocess
. This would also make it more trackable and people would know which components of Boost are needed instead of fetching the whole thing.
Describe alternatives you've considered
Adding openvdb-extra.cmake
with the proper target_link_libraries
calls after FetchContent_Declare
fixes the issue, but it's not obvious that people should do that. It also pollutes the project and doesn't look future-proof.
FetchContent_Declare(
openvdb
URL https://github.com/AcademySoftwareFoundation/openvdb/archive/refs/tags/v11.0.0.zip
OVERRIDE_FIND_PACKAGE
EXCLUDE_FROM_ALL
)
file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/openvdb-extra.cmake
[=[
if(TARGET openvdb_static)
target_link_libraries(openvdb_static PRIVATE Boost::numeric_conversion Boost::interprocess)
endif()
if(TARGET openvdb_shared)
target_link_libraries(openvdb_shared PRIVATE Boost::numeric_conversion Boost::interprocess)
endif()
]=])