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

@@ -14,6 +14,8 @@ add_subdirectory(mikktspace)
add_subdirectory(eigen)
add_subdirectory(sky)
add_subdirectory(openvdb)
if(WITH_AUDASPACE)
add_subdirectory(audaspace)
endif()
@@ -55,10 +57,6 @@ if(WITH_UV_SLIM)
add_subdirectory(slim)
endif()
if(WITH_OPENVDB)
add_subdirectory(openvdb)
endif()
if(WITH_QUADRIFLOW)
add_subdirectory(quadriflow)
endif()

View File

@@ -38,16 +38,6 @@ set(INC_SYS
${ZLIB_INCLUDE_DIRS}
)
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
)
endif()
set(SRC
intern/manta_python_API.cpp
intern/manta_fluid_API.cpp
@@ -65,6 +55,7 @@ set(LIB
PRIVATE bf::blenlib
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc
PRIVATE bf::dependencies::optional::openvdb
PRIVATE bf::dependencies::optional::tbb
extern_mantaflow

View File

@@ -2,36 +2,25 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
.
)
set(INC_SYS
)
set(SRC
openvdb_capi.h
openvdb_fwd.hh
)
set(LIB
PRIVATE bf::intern::guardedalloc
)
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
list(APPEND INC
PUBLIC .
)
list(APPEND SRC
openvdb_capi.h
openvdb_fwd.hh
openvdb_capi.cc
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
PUBLIC bf::dependencies::optional::openvdb
)
blender_add_lib(bf_intern_openvdb "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
else()
# Empty target
add_library(bf_intern_openvdb INTERFACE)
endif()
blender_add_lib(bf_intern_openvdb "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_library(bf::intern::optional::openvdb ALIAS bf_intern_openvdb)