CMake: Modernize the optional TBB dependency #124916

Merged
Jesse Yurkovich merged 9 commits from deadpin/blender:cleanup-cmake-moderntbb into main 2024-07-19 23:31:16 +02:00
40 changed files with 41 additions and 320 deletions

View File

@ -1679,6 +1679,10 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
endif()
endif()
# -----------------------------------------------------------------------------
# Common dependency targets
deadpin marked this conversation as resolved Outdated

I am aware this was likely copy/pasted from my initial stab, but I feel some non optional targets will likely make it into this file as well at one point, I'd drop optional from this comment for that reason.

I am aware this was likely copy/pasted from my initial stab, but I feel some non optional targets will likely make it into this file as well at one point, I'd drop `optional` from this comment for that reason.
include(dependency_targets)
# -----------------------------------------------------------------------------
# Ninja Job Limiting

View File

@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2024 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Common modern targets for the blender dependencies
#
# The optional dependencies in the bf::dependencies::optional namespace
# will always exist, but will only be populated if the dep is actually
# enabled. Doing it this way, prevents us from having to sprinkle
# if(WITH_SOMEDEP) all over cmake, and you can just add
# `bf::dependencies::optional::somedep` to the LIB section without
# having to worry if it's enabled or not at the consumer site.
# -----------------------------------------------------------------------------
# Configure TBB
add_library(bf_deps_optional_tbb INTERFACE)
add_library(bf::dependencies::optional::tbb ALIAS bf_deps_optional_tbb)
if(WITH_TBB)
target_compile_definitions(bf_deps_optional_tbb INTERFACE WITH_TBB)
target_include_directories(bf_deps_optional_tbb SYSTEM INTERFACE ${TBB_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_tbb INTERFACE ${TBB_LIBRARIES})
endif()

View File

@ -86,15 +86,6 @@ if(WITH_MANTA_NUMPY AND WITH_PYTHON_NUMPY)
)
endif()
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_OPENVDB)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
@ -245,6 +236,7 @@ if(WITH_MANTA_NUMPY AND WITH_PYTHON_NUMPY)
endif()
set(LIB
PRIVATE bf::dependencies::optional::tbb
${PYTHON_LINKFLAGS}
${PYTHON_LIBRARIES}
)

View File

@ -38,15 +38,6 @@ set(INC_SYS
${ZLIB_INCLUDE_DIRS}
)
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
@ -74,6 +65,7 @@ set(LIB
PRIVATE bf::blenlib
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc
PRIVATE bf::dependencies::optional::tbb
extern_mantaflow
${PYTHON_LINKFLAGS}

View File

@ -5,11 +5,7 @@
add_library(bf_intern_mikktspace INTERFACE)
target_include_directories(bf_intern_mikktspace INTERFACE .)
if(WITH_TBB)
target_compile_definitions(bf_intern_mikktspace INTERFACE -DWITH_TBB)
target_include_directories(bf_intern_mikktspace INTERFACE ${TBB_INCLUDE_DIRS})
target_link_libraries(bf_intern_mikktspace INTERFACE ${TBB_LIBRARIES})
endif()
target_link_libraries(bf_intern_mikktspace INTERFACE bf::dependencies::optional::tbb)
# CMake 3.19+ allows one to populate the interface library with
# source files to show in the IDE.

View File

@ -806,18 +806,6 @@ if(WITH_XR_OPENXR)
add_definitions(-DWITH_XR_OPENXR)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_ANIM_BAKLAVA)
endif()

View File

@ -412,6 +412,7 @@ set(LIB
extern_wcwidth
PRIVATE bf::intern::atomic
PRIVATE extern_fmtlib
PUBLIC bf::dependencies::optional::tbb
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}
)
@ -428,18 +429,6 @@ if(WITH_MEM_VALGRIND)
add_definitions(-DWITH_MEM_VALGRIND)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_GMP)
add_definitions(-DWITH_GMP)

View File

@ -83,13 +83,6 @@ if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
endif()
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
endif()

View File

@ -202,19 +202,11 @@ if(WITH_GMP)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -576,10 +576,6 @@ if(WITH_COMPOSITOR_CPU)
)
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -369,10 +369,6 @@ set(shader_create_info_list_file "${CMAKE_CURRENT_BINARY_DIR}/compositor_shader_
file(GENERATE OUTPUT ${shader_create_info_list_file} CONTENT "${SHADER_CREATE_INFOS_CONTENT}")
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -168,18 +168,6 @@ if(WITH_PYTHON)
)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_ANIM_BAKLAVA)
endif()

View File

@ -844,21 +844,11 @@ if(WITH_GTESTS)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_draw "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -41,18 +41,6 @@ set(LIB
PRIVATE bf::intern::guardedalloc
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh

View File

@ -44,10 +44,6 @@ set(LIB
)
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -50,17 +50,5 @@ set(LIB
extern_fmtlib
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_grease_pencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_dependencies(bf_editor_curves bf_rna)

View File

@ -85,18 +85,6 @@ if(WITH_GMP)
add_definitions(-DWITH_GMP)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh

View File

@ -60,10 +60,6 @@ if(WITH_FREESTYLE)
endif()
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -166,13 +166,6 @@ set(LIB
PRIVATE bf::intern::guardedalloc
)
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
endif()

View File

@ -53,18 +53,6 @@ set(LIB
PRIVATE bf::intern::guardedalloc
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_space_clip "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh

View File

@ -62,17 +62,6 @@ if(WITH_IMAGE_WEBP)
add_definitions(-DWITH_WEBP)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -90,19 +90,11 @@ if(WITH_OPENVDB)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -76,16 +76,6 @@ if(WITH_AUDASPACE)
add_definitions(-DWITH_AUDASPACE)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -106,18 +106,6 @@ if(WITH_XR_OPENXR)
add_definitions(-DWITH_XR_OPENXR)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh

View File

@ -128,18 +128,6 @@ set(LIB
PRIVATE bf::intern::guardedalloc
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.hh

View File

@ -48,19 +48,11 @@ set(LIB
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_functions "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -114,18 +114,6 @@ if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_GMP)
add_definitions(-DWITH_GMP)

View File

@ -72,19 +72,11 @@ set(SRC
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
endif()
set(LIB

View File

@ -835,18 +835,6 @@ if(WITH_OPENCOLORIO)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
target_link_libraries(bf_gpu PUBLIC
bf_compositor_shaders

View File

@ -161,18 +161,6 @@ if(WITH_IMAGE_WEBP)
add_definitions(-DWITH_WEBP)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
list(APPEND INC
../../../intern/opencolorio
)

View File

@ -102,18 +102,6 @@ if(WITH_BOOST)
)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_io_alembic "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(WITH_GTESTS)

View File

@ -27,7 +27,6 @@ endif()
# USD headers use deprecated TBB headers, silence warning.
add_definitions(-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1)
add_definitions(-DWITH_TBB)
# Check if USD has the imaging headers available, if they are
# add a USD_HAS_IMAGING define so code can dynamically detect this.

View File

@ -62,12 +62,6 @@ set(LIB
PRIVATE bf::extern::fmtlib
)
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS ${TBB_INCLUDE_DIRS})
list(APPEND LIB ${TBB_LIBRARIES})
endif()
blender_add_lib(bf_io_wavefront_obj "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(WITH_GTESTS)

View File

@ -18,6 +18,7 @@ set(INC_SYS
set(LIB
PRIVATE bf::intern::atomic
PRIVATE bf::intern::guardedalloc
PRIVATE bf::dependencies::optional::tbb
)
add_definitions(-DWITH_DNA_GHASH)
@ -159,6 +160,7 @@ set(SRC
set(LIB
PRIVATE bf::intern::atomic
PRIVATE bf::intern::guardedalloc
PRIVATE bf::dependencies::optional::tbb
)
blender_add_lib(bf_dna_blenlib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -451,6 +451,7 @@ target_link_libraries(makesrna PRIVATE bf_dna)
target_link_libraries(makesrna PRIVATE bf::intern::atomic)
target_link_libraries(makesrna PRIVATE bf::intern::guardedalloc)
target_link_libraries(makesrna PRIVATE bf_dna_blenlib)
target_link_libraries(makesrna PRIVATE bf::dependencies::optional::tbb)
if(WIN32 AND NOT UNIX)
if(DEFINED PTHREADS_LIBRARIES)
@ -484,6 +485,7 @@ set(SRC
set(LIB
PRIVATE bf::animrig
PRIVATE bf::dna
PRIVATE bf::dependencies::optional::tbb
PRIVATE extern_fmtlib
bf_editor_space_api

View File

@ -214,19 +214,11 @@ if(WITH_GMP)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
if(WITH_OPENVDB)

View File

@ -160,10 +160,6 @@ if(WITH_BULLET)
endif()
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -276,10 +276,6 @@ if(WITH_BULLET)
endif()
if(WITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.

View File

@ -170,19 +170,11 @@ if(WITH_FREESTYLE)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
if(WIN32)
# TBB includes Windows.h which will define min/max macros
# that will collide with the stl versions.
add_definitions(-DNOMINMAX)
endif()
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib(bf_nodes_shader "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -97,16 +97,4 @@ if(WITH_HYDRA)
add_subdirectory(hydra)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
blender_add_lib_nolist(bf_render "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")