Files
test2/source/blender/nodes/CMakeLists.txt
Jesse Yurkovich ec4fc2d34a CMake: Modernize the optional TBB dependency
This continues the cmake modernization effort and introduces support for
allowing our optional dependencies to integrate properly. TBB is added
here as it's proven troublesome to maintain correctly.

Currently the only Blender project which uses the TBB headers directly
is `blenlib`.  However, all downstream projects which require blenlib as
their dependency, and wish to properly make use of its threading
facilities, needed to define various TBB items in their CMake files. Not
only is this unnecessary and arcane, but several projects didn't do this
and ended up not using threading as well as producing ODR violations
along the way[1].

This PR makes TBB a modern dependency and exposes it PUBLIC'ly from
`blenlib`.  All downstream projects which depend on blenlib will now
receive everything they require from TBB automatically. This includes
the `WITH_TBB` define, the headers, and the library itself.

[1] blender/blender@05241f47f5

Pull Request: https://projects.blender.org/blender/blender/pulls/124916
2024-07-19 23:30:56 +02:00

208 lines
4.2 KiB
CMake

# SPDX-FileCopyrightText: 2006 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(DISCOVER_NODES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/intern/discover_nodes.py)
# Creates a library with the given name that exposes one function which calls
# the register functions of all nodes in the provided source files.
function(add_node_discovery
lib_name
sources
output_file
output_function
)
set(extra_args "")
# See `add_definitions(-DUSE_MAKEFILE_WORKAROUND)` comment for `makesrna`.
if(CMAKE_GENERATOR MATCHES ".*Unix Makefiles")
set(extra_args "--use-makefile-workaround")
endif()
add_custom_command(
OUTPUT
${output_file}
COMMAND
${PYTHON_EXECUTABLE}
${DISCOVER_NODES_PATH}
${CMAKE_CURRENT_SOURCE_DIR}
${output_file}
${output_function}
${sources}
${extra_args}
DEPENDS
${SRC}
${DISCOVER_NODES_PATH}
)
set_source_files_properties(${output_file} PROPERTIES GENERATED TRUE)
add_library(${lib_name} ${output_file})
endfunction()
add_subdirectory(composite)
add_subdirectory(function)
add_subdirectory(geometry)
add_subdirectory(shader)
add_subdirectory(texture)
set(INC
.
composite
function
geometry
intern
shader
texture
../editors/include
../blenkernel
../blenloader
../blentranslation
../bmesh
../depsgraph
../functions
../geometry
../gpu
../imbuf
../makesrna
../modifiers
../render
../windowmanager
# RNA_prototypes.hh
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(INC_SYS
)
set(SRC
intern/derived_node_tree.cc
intern/geometry_nodes_execute.cc
intern/geometry_nodes_gizmos.cc
intern/geometry_nodes_lazy_function.cc
intern/geometry_nodes_log.cc
intern/inverse_eval.cc
intern/math_functions.cc
intern/node_common.cc
intern/node_declaration.cc
intern/node_exec.cc
intern/node_geometry_exec.cc
intern/node_multi_function.cc
intern/node_register.cc
intern/node_rna_define.cc
intern/node_socket.cc
intern/node_socket_declarations.cc
intern/node_util.cc
intern/partial_eval.cc
intern/socket_search_link.cc
intern/value_elem.cc
NOD_common.h
NOD_composite.hh
NOD_derived_node_tree.hh
NOD_geometry.hh
NOD_geometry_exec.hh
NOD_geometry_nodes_execute.hh
NOD_geometry_nodes_gizmos.hh
NOD_geometry_nodes_lazy_function.hh
NOD_geometry_nodes_log.hh
NOD_inverse_eval_params.hh
NOD_inverse_eval_path.hh
NOD_inverse_eval_run.hh
NOD_math_functions.hh
NOD_multi_function.hh
NOD_node_declaration.hh
NOD_node_extra_info.hh
NOD_node_in_compute_context.hh
NOD_partial_eval.hh
NOD_register.hh
NOD_rna_define.hh
NOD_shader.h
NOD_socket.hh
NOD_socket_declarations.hh
NOD_socket_declarations_geometry.hh
NOD_socket_items.hh
NOD_socket_items_ops.hh
NOD_socket_search_link.hh
NOD_static_types.h
NOD_texture.h
NOD_value_elem.hh
NOD_value_elem_eval.hh
intern/node_common.h
intern/node_exec.hh
intern/node_util.hh
)
set(LIB
PRIVATE bf::blenlib
bf_bmesh
PRIVATE bf::depsgraph
PRIVATE bf::dna
bf_functions
PRIVATE bf::intern::guardedalloc
bf_nodes_composite
bf_nodes_function
bf_nodes_geometry
bf_nodes_shader
bf_nodes_texture
PRIVATE bf::extern::fmtlib
)
if(WITH_BULLET)
list(APPEND INC_SYS
${BULLET_INCLUDE_DIRS}
../../../intern/rigidbody
)
list(APPEND LIB
${BULLET_LIBRARIES}
)
add_definitions(-DWITH_BULLET)
endif()
if(WITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
endif()
if(WITH_IMAGE_OPENEXR)
add_definitions(-DWITH_OPENEXR)
endif()
if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
endif()
if(WITH_GMP)
add_definitions(-DWITH_GMP)
list(APPEND INC_SYS
${GMP_INCLUDE_DIRS}
)
list(APPEND LIB
${GMP_LIBRARIES}
)
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}")
# RNA_prototypes.hh
add_dependencies(bf_nodes bf_rna)