Cleanup: CMake: Modernize bf_intern_openvdb dependencies

This follows the other CMake "modernization" commits, this time for
`bf_intern_openvdb` and the OpenVDB dependency itself.

The difference with this one is that `intern/openvdb` becomes an
"optional" dependency itself. This is because downstream consumers often
want to include this dependency rather than openvdb directly, so this
target must also be optional. Optional, in this case, means the target
always exists but may be entirely empty.

Summary
- If you are using BKE APIs to access openvdb features, then use the
  `bf::blenkernel` target
- If you are only using `intern/openvdb` APIs then use the
  `bf::intern::optional::openvdb` target (rare)
- For all other cases, use the `bf::dependencies::optional::openvdb`
  target (rare)

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/137071
This commit is contained in:
Jesse Yurkovich
2025-08-12 21:26:38 +02:00
committed by Jesse Yurkovich
parent 42b6c7f804
commit 0240a1f32f
18 changed files with 43 additions and 216 deletions

View File

@@ -38,6 +38,30 @@ if(WITH_MANIFOLD)
endif()
endif()
# -----------------------------------------------------------------------------
# Configure OpenVDB
add_library(bf_deps_optional_openvdb INTERFACE)
add_library(bf::dependencies::optional::openvdb ALIAS bf_deps_optional_openvdb)
if(WITH_OPENVDB)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE WITH_OPENVDB)
if(WITH_OPENVDB_BLOSC)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE WITH_OPENVDB_BLOSC)
endif()
if(WITH_OPENVDB_3_ABI_COMPATIBLE)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE OPENVDB_3_ABI_COMPATIBLE)
endif()
target_include_directories(bf_deps_optional_openvdb SYSTEM INTERFACE ${OPENVDB_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_openvdb
INTERFACE
${OPENVDB_LIBRARIES}
bf::dependencies::optional::tbb
)
endif()
# -----------------------------------------------------------------------------
# Configure Eigen