[BUG] OpenVDB::nanovdb imported target lacks NANOVDB_USE_OPENVDB, so NanoVDB<->OpenVDB conversion does not compile against an installed OpenVDB

Open Beginner friendly
#2,345 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp
Domain
build-system

Research direction

Start in cmake/FindOpenVDB.cmake around lines 799–802 and compare the installed OpenVDB::nanovdb target with nanovdb/nanovdb/CMakeLists.txt lines 339–346. Configure and build vdb_tool with OPENVDB_BUILD_CORE=OFF and OPENVDB_TOOL_USE_NANO=ON against an installed OpenVDB. Done means the imported target provides the same OpenVDB support interface and NanoVDB conversion compiles.

Written by the indexing model from the issue text.

Description

bug

Symptom:
Configuring vdb_tool against an installed OpenVDB (OPENVDB_BUILD_CORE=OFF, OPENVDB_TOOL_USE_NANO=ON) succeeds - find_package(OpenVDB COMPONENTS nanovdb) reports the component found - but compilation fails in Tool.h:

Tool.h:2400: error: 'openToNanoVDB' is not a member of 'nanovdb::tools'
nanovdb/tools/CreateNanoGrid.h:333: error: '... openvdb::Grid<...>' has no member named 'gridClass'
nanovdb/tools/CreateNanoGrid.h:332: error: '... openvdb::Grid<...>' has no member named 'map'

i.e. CreateNanoGrid.h is being compiled with its OpenVDB support disabled, and treats an openvdb::Grid as a NanoVDB grid.

Cause:
the macro is only ever set on the in-tree target. nanovdb/nanovdb/CMakeLists.txt lines 339–346:

if(NANOVDB_USE_OPENVDB)
...
target_link_libraries(nanovdb INTERFACE openvdb) # or OpenVDB::openvdb
target_compile_definitions(nanovdb INTERFACE -DNANOVDB_USE_OPENVDB)
endif()

The installed package's equivalent, cmake/FindOpenVDB.cmake lines 799-802, creates OpenVDB::nanovdb as an INTERFACE IMPORTED target carrying only INTERFACE_INCLUDE_DIRECTORIES - no NANOVDB_USE_OPENVDB definition and no link dependency on OpenVDB::openvdb. The in-tree and installed targets therefore have different contracts, and every consumer that worked in-tree breaks when built standalone.

Reproduce:
cmake --install --prefix , then configure any project with find_package(OpenVDB REQUIRED COMPONENTS openvdb nanovdb) and compile a TU that calls nanovdb::tools::createNanoGrid(openvdb_grid). vdb_tool with OPENVDB_BUILD_CORE=OFF -DOPENVDB_TOOL_USE_NANO=ON is a ready-made case. Observed on v13.1.0 (4d95e56b), Ubuntu 24.04, gcc 13.3, CMake 3.28.

Suggested fix:
in FindOpenVDB.cmake, when both the openvdb and nanovdb components are requested, give OpenVDB::nanovdb the same interface the in-tree target has:

set_target_properties(OpenVDB::nanovdb PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "NANOVDB_USE_OPENVDB"
INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb")

(Optionally also NANOVDB_USE_TBB / NANOVDB_USE_BLOSC / NANOVDB_USE_ZIP, mirroring lines 61-88 of openvdb_cmd/vdb_tool/CMakeLists.txt, which currently re-derives those itself but not NANOVDB_USE_OPENVDB.)

Not covered by CI:
no workflow builds vdb_tool standalone with NanoVDB.

Dominant language
C++
Stars
3.4k
Forks
777
Avg merge
3d 1h
Merged PRs (30d)
33

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AcademySoftwareFoundation/openvdb

All issues in AcademySoftwareFoundation/openvdb

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.