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
25 lines
1011 B
CMake
25 lines
1011 B
CMake
# 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()
|