Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,10 @@ endif()


# --TBB
find_package(TBB CONFIG)
if(TBB_DIR)
# Found in CONFIG mode.
set(TBB_tbb_LIBRARY TBB::tbb)
set(PXR_FIND_TBB_IN_CONFIG ON)
else()
find_package(TBB CONFIG COMPONENTS tbb)
if(NOT TBB_FOUND)
find_package(TBB REQUIRED COMPONENTS tbb)
set(PXR_FIND_TBB_IN_CONFIG OFF)
endif()
add_definitions(${TBB_DEFINITIONS})

# --math
if(WIN32)
Expand Down
123 changes: 96 additions & 27 deletions cmake/modules/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,27 @@ if(NOT TBB_FOUND)
set(TBB_ARCHITECTURE "ia32")
endif()

# Set the TBB search library path search suffix based on the version of VC
# Set the TBB search library/runtime path search suffix based on the version of VC
if(WINDOWS_STORE)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11_ui")
set(TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc11_ui")
elseif(MSVC14)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc14")
set(TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc14")
elseif(MSVC12)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc12")
set(TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc12")
elseif(MSVC11)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11")
set(TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc11")
elseif(MSVC10)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc10")
set(TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc10")
endif()

# Add the library path search suffix for the VC independent version of TBB
# Add the library/runtime path search suffix for the VC independent version of TBB
list(APPEND TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc_mt")
list(APPEND TBB_RUNTIME_PATH_SUFFIX "bin/${TBB_ARCHITECTURE}/vc_mt")

elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# OS X
Expand All @@ -176,12 +182,13 @@ if(NOT TBB_FOUND)
endif()
endif()

# The above TBB_LIB_PATH_SUFFIX is based on where Intel puts the libraries
# The above TBB_LIB_PATH_SUFFIX/TBB_RUNTIME_PATH_SUFFIX is based on where Intel puts the libraries
# in the package of prebuilt libraries it distributes. However, users may
# install these shared libraries into the more conventional "lib" directory
# install these shared libraries into the more conventional "lib"/"bin" directory
# (especially when building from source), so we add that as an additional
# location to search.
list(APPEND TBB_LIB_PATH_SUFFIX "lib")
list(APPEND TBB_RUNTIME_PATH_SUFFIX "bin")

##################################
# Find the TBB include dir
Expand Down Expand Up @@ -224,13 +231,13 @@ if(NOT TBB_FOUND)
endif()

if(TBB_VERSION VERSION_LESS 4.3)
set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc tbb)
set(TBB_SEARCH_COMPONENTS tbb_preview tbbmalloc tbb)
else()
set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb)
set(TBB_SEARCH_COMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb)
endif()

# Find each component
foreach(_comp ${TBB_SEARCH_COMPOMPONENTS})
foreach(_comp ${TBB_SEARCH_COMPONENTS})
if(";${TBB_FIND_COMPONENTS};tbb" MATCHES ";${_comp};")

if(${_comp} STREQUAL tbb)
Expand All @@ -250,6 +257,32 @@ if(NOT TBB_FOUND)
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})

# On Windows platforms also looks for .dll binaries.
# If we find some, assume TBB is built as a shared library with the .lib/.dll pair,
# otherwise assume it is built as a static library
set(TBB_${_comp}_TARGET_TYPE SHARED)
if(WIN32)
find_file(TBB_${_comp}_SHARED_LIBRARY_RELEASE
NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}${_lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES ${TBB_RUNTIME_PATH_SUFFIX})

find_file(TBB_${_comp}_SHARED_LIBRARY_DEBUG
NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}${_lib_name}_debug${CMAKE_SHARED_LIBRARY_SUFFIX}
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES ${TBB_RUNTIME_PATH_SUFFIX})

if(TBB_${_comp}_LIBRARY_RELEASE AND TBB_${_comp}_SHARED_LIBRARY_RELEASE)
set(TBB_${_comp}_TARGET_TYPE SHARED)
elseif(TBB_${_comp}_LIBRARY_DEBUG AND TBB_${_comp}_SHARED_LIBRARY_DEBUG)
set(TBB_${_comp}_TARGET_TYPE SHARED)
else()
set(TBB_${_comp}_TARGET_TYPE STATIC)
endif()
endif()

if(TBB_${_comp}_LIBRARY_DEBUG)
list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}")
endif()
Expand All @@ -270,6 +303,7 @@ if(NOT TBB_FOUND)
mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE)
mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG)
mark_as_advanced(TBB_${_comp}_LIBRARY)
mark_as_advanced(TBB_${_comp}_TARGET_TYPE)

endif()
endforeach()
Expand Down Expand Up @@ -302,26 +336,61 @@ if(NOT TBB_FOUND)
##################################

if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND)
add_library(TBB::tbb SHARED IMPORTED)
set_target_properties(TBB::tbb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}
IMPORTED_LOCATION ${TBB_LIBRARIES})
if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG)
set_target_properties(TBB::tbb PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:TBB_USE_DEBUG=1>"
IMPORTED_LOCATION_DEBUG ${TBB_LIBRARIES_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_DEBUG}
IMPORTED_LOCATION_RELEASE ${TBB_LIBRARIES_RELEASE}
IMPORTED_LOCATION_MINSIZEREL ${TBB_LIBRARIES_RELEASE}
)
elseif(TBB_LIBRARIES_RELEASE)
set_target_properties(TBB::tbb PROPERTIES IMPORTED_LOCATION ${TBB_LIBRARIES_RELEASE})
else()
set_target_properties(TBB::tbb PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS_DEBUG}"
IMPORTED_LOCATION ${TBB_LIBRARIES_DEBUG}
)
endif()

foreach(_comp ${TBB_SEARCH_COMPONENTS})
if(";${TBB_FIND_COMPONENTS};tbb" MATCHES ";${_comp};")

add_library(TBB::${_comp} ${TBB_${_comp}_TARGET_TYPE} IMPORTED)
set_property(TARGET TBB::${_comp} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}
)

if(WIN32 AND TBB_${_comp}_SHARED_LIBRARY_${TBB_BUILD_TYPE})
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_IMPLIB ${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}
IMPORTED_LOCATION ${TBB_${_comp}_SHARED_LIBRARY_${TBB_BUILD_TYPE}})
else()
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_LOCATION ${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}})
endif()

if(TBB_${_comp}_LIBRARY_DEBUG)
set_property(TARGET TBB::${_comp} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_property(TARGET TBB::${_comp} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:TBB_USE_DEBUG=1>")

if(WIN32 AND TBB_${_comp}_SHARED_LIBRARY_DEBUG)
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_IMPLIB_DEBUG ${TBB_${_comp}_LIBRARY_DEBUG}
IMPORTED_IMPLIB_RELWITHDEBINFO ${TBB_${_comp}_LIBRARY_DEBUG}

IMPORTED_LOCATION_DEBUG ${TBB_${_comp}_SHARED_LIBRARY_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_${_comp}_SHARED_LIBRARY_DEBUG})
else()
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_LOCATION_DEBUG ${TBB_${_comp}_LIBRARY_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_${_comp}_LIBRARY_DEBUG})
endif()
endif()

if(TBB_${_comp}_LIBRARY_RELEASE)
set_property(TARGET TBB::${_comp} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)

if(WIN32 AND TBB_${_comp}_SHARED_LIBRARY_RELEASE)
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_IMPLIB_RELEASE ${TBB_${_comp}_LIBRARY_RELEASE}
IMPORTED_IMPLIB_MINSIZEREL ${TBB_${_comp}_LIBRARY_RELEASE}

IMPORTED_LOCATION_RELEASE ${TBB_${_comp}_SHARED_LIBRARY_RELEASE}
IMPORTED_LOCATION_MINSIZEREL ${TBB_${_comp}_SHARED_LIBRARY_RELEASE})
else()
set_target_properties(TBB::${_comp} PROPERTIES
IMPORTED_LOCATION_RELEASE ${TBB_${_comp}_LIBRARY_RELEASE}
IMPORTED_LOCATION_MINSIZEREL ${TBB_${_comp}_LIBRARY_RELEASE})
endif()
endif()

endif()
endforeach()
endif()

mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES)
Expand Down
5 changes: 1 addition & 4 deletions pxr/base/plug/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pxr_library(plug
js
trace
work
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
interfaceFactory
Expand Down
5 changes: 1 addition & 4 deletions pxr/base/tf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ pxr_library(tf
LIBRARIES
arch
${WINLIBS}
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
anyUniquePtr
Expand Down
5 changes: 1 addition & 4 deletions pxr/base/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ pxr_library(trace
arch
js
tf
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
aggregateTree
Expand Down
5 changes: 1 addition & 4 deletions pxr/base/vt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ pxr_library(vt
tf
gf
trace
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
array
Expand Down
5 changes: 1 addition & 4 deletions pxr/base/work/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ pxr_library(work
LIBRARIES
tf
trace
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
detachedTask
Expand Down
5 changes: 1 addition & 4 deletions pxr/imaging/hd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ pxr_library(hd
hf
pxOsd
sdr
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
aov
Expand Down
5 changes: 1 addition & 4 deletions pxr/imaging/hdGp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ pxr_library(hdGp
LIBRARIES
hd
hf
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
generativeProcedural
Expand Down
3 changes: 1 addition & 2 deletions pxr/imaging/hdSt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ pxr_library(hdSt
sdr
tf
trace
${TBB_tbb_LIBRARY}
TBB::tbb
${OPENSUBDIV_LIBRARIES}
${optionalLibs}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
${OPENSUBDIV_INCLUDE_DIR}
${optionalIncludeDirs}

Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/hdsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pxr_library(hdsi
hf
hd
pxOsd
TBB::tbb

PUBLIC_CLASSES
computeSceneIndexDiff
Expand Down
2 changes: 0 additions & 2 deletions pxr/imaging/plugin/hdEmbree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ pxr_plugin(hdEmbree
hf
hd
hdx
${TBB_tbb_LIBRARY}
${EMBREE_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
${EMBREE_INCLUDE_DIR}

PUBLIC_CLASSES
Expand Down
9 changes: 0 additions & 9 deletions pxr/imaging/plugin/hdEmbree/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@
#include <embree3/rtcore.h>
#include <embree3/rtcore_geometry.h>
#include <embree3/rtcore_ray.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_queue.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/parallel_for.h>
#include <tbb/parallel_for_each.h>
#include <tbb/spin_mutex.h>
#include <tbb/task_group.h>
#ifdef PXR_PYTHON_SUPPORT_ENABLED
#include "pxr/base/tf/pySafePython.h"
#endif // PXR_PYTHON_SUPPORT_ENABLED
2 changes: 0 additions & 2 deletions pxr/imaging/plugin/hdStorm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ pxr_plugin(hdStorm
hd
hdSt
${OPENSUBDIV_LIBRARIES}
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
${OPENSUBDIV_INCLUDE_DIR}

PUBLIC_CLASSES
Expand Down
4 changes: 0 additions & 4 deletions pxr/imaging/plugin/hdStorm/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@
#include <unordered_set>
#include <utility>
#include <vector>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_queue.h>
#include <tbb/spin_mutex.h>
#ifdef PXR_PYTHON_SUPPORT_ENABLED
#include "pxr/base/tf/pySafePython.h"
#endif // PXR_PYTHON_SUPPORT_ENABLED
2 changes: 2 additions & 0 deletions pxr/pxrConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(PXR_VERSION "@PXR_VERSION@")

include(CMakeFindDependencyMacro)

find_dependency(TBB)

# If Python support was enabled for this USD build, find the import
# targets by invoking the appropriate FindPython module. Use the same
# LIBRARY and INCLUDE_DIR settings from the original build if they
Expand Down
5 changes: 1 addition & 4 deletions pxr/usd/ar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pxr_library(ar
tf
plug
vt
${TBB_tbb_LIBRARY}

INCLUDE_DIRS
${TBB_INCLUDE_DIRS}
TBB::tbb

PUBLIC_CLASSES
asset
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/ar/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "pxr/base/tf/unicodeUtils.h"

#include <tbb/concurrent_hash_map.h>
#include <tbb/enumerable_thread_specific.h>

#include <memory>
#include <mutex>
Expand Down
Loading