openvdb
openvdb copied to clipboard
[BUILD] Allow building openvdb in a super project with TBB on its side
Environment
Operating System: all Version / Commit SHA: 36898a CMake Version: 3.20 Compiler: all
Describe the problem
If I put openvdb in a larger project with tbb on its side and use add_subdirectory for both of them and it still tries to find_package(TBB) even though the target is already there. The solution is quite simple and consists of adding a
if (NOT TARGET TBB::tbb) on line 123 of openvdb/openvdb/CMakeLists.txt so that the code becomes:
if (NOT TARGET TBB::tbb)
find_package(TBB ${MINIMUM_TBB_VERSION} REQUIRED COMPONENTS tbb)
if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_TBB_VERSION)
if(${Tbb_VERSION} VERSION_LESS FUTURE_MINIMUM_TBB_VERSION)
message(DEPRECATION "Support for TBB versions < ${FUTURE_MINIMUM_TBB_VERSION} "
"is deprecated and will be removed.")
endif()
endif()
endif()
To Reproduce
Steps to reproduce the behavior:
- Checkout repo '...'
- Run CMake '....'
- Build with '....'
- See error
Additional context
(Add any other context about the problem here.)