AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb

[BUILD] Allow building openvdb in a super project with TBB on its side

Open
#1,044 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.4k
Forks
774
Avg merge
3d 9h
Merged PRs (30d)
34

Description

### 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:
1. Checkout repo '...'
2. Run CMake '....'
3. Build with '....'
4. See error

### Additional context
(Add any other context about the problem here.)

Contributor guide

Open the contributing guide

Research direction

Start in openvdb/openvdb/CMakeLists.txt around line 123 and inspect how the TBB dependency is discovered when OpenVDB and TBB are added as sibling subdirectories. Reproduce the configuration with both projects present, then verify that an existing TBB::tbb target avoids the unnecessary package lookup and that the project configures successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.