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 (4d95e56), 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.
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 (4d95e56), 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.