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

@@ -590,6 +590,7 @@ set(LIB
PRIVATE bf::intern::clog
bf_intern_ghost
PRIVATE bf::intern::guardedalloc
PUBLIC bf::intern::optional::openvdb # Contains intern-openvdb items in public headers
bf_intern_libmv # Uses stub when disabled.
bf_intern_mikktspace
bf_intern_opensubdiv # Uses stub when disabled.
@@ -789,20 +790,6 @@ if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_QUADRIFLOW)
list(APPEND INC
../../../intern/quadriflow

View File

@@ -7,8 +7,10 @@
*/
#include "BLI_math_base.hh"
#include "BLI_math_constants.h"
#include "BKE_ocean.h"
#include "ocean_intern.h"
#include <algorithm>

View File

@@ -780,20 +780,6 @@ if(WITH_OPENSUBDIV)
)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_MOD_FLUID)
list(APPEND INC
../../../intern/mantaflow/extern

View File

@@ -79,20 +79,6 @@ if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_TBB)
if(WIN32)
# TBB includes `Windows.h` which will define min/max macros

View File

@@ -57,19 +57,6 @@ set(LIB
PRIVATE bf::windowmanager
)
if(WITH_OPENVDB)
list(APPEND INC
../../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
blender_add_lib(bf_editor_space_spreadsheet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh dna_type_offsets.h

View File

@@ -124,20 +124,6 @@ if(WITH_UV_SLIM)
add_definitions(-DWITH_UV_SLIM)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_GMP)
add_definitions(-DWITH_GMP)

View File

@@ -222,19 +222,6 @@ list(APPEND LIB
${TBB_LIBRARIES}
)
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC
../../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
)
endif()
if(WITH_MATERIALX)
add_definitions(-DWITH_MATERIALX)
list(APPEND LIB MaterialXCore)

View File

@@ -387,23 +387,6 @@ if(WITH_OPENSUBDIV)
)
add_definitions(-DWITH_OPENSUBDIV)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB)
if(WITH_OPENVDB_BLOSC)
add_definitions(-DWITH_OPENVDB_BLOSC)
endif()
endif()
if(WITH_INPUT_NDOF)
add_definitions(-DWITH_INPUT_NDOF)
@@ -479,6 +462,7 @@ set(SRC
set(LIB
PRIVATE bf::animrig
PRIVATE bf::dna
PRIVATE bf::dependencies::optional::openvdb
PRIVATE bf::dependencies::optional::tbb
PRIVATE extern_fmtlib
bf_editor_space_api

View File

@@ -222,20 +222,6 @@ if(WITH_TBB)
endif()
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_SIMULATION_DATABLOCK)
endif()

View File

@@ -228,16 +228,6 @@ if(WITH_GMP)
)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_library(bf::nodes ALIAS bf_nodes)

View File

@@ -350,16 +350,6 @@ if(WITH_GMP)
)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
add_node_discovery(
bf_nodes_geometry_generated
"${SRC}"

View File

@@ -320,17 +320,6 @@ if(WITH_IO_GREASE_PENCIL)
add_definitions(-DWITH_IO_GREASE_PENCIL)
endif()
if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB)
list(APPEND INC
../../../../intern/openvdb
)
endif()
if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
list(APPEND INC