AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb
[BUILD] CMake RelWithDebInfo produces invalid TBB library path resulting in an error
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 774
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 34
Description
### Environment
**Operating System:** Linux CentOS 7.0 (Core)
**Version / Commit SHA:** VDB 9.0
**CMake Version:** 3.12
**Compiler:** clang++ 12.0.1
### Describe the problem
Recently we updated from OpenVDB 8.0.1 to 9.0.0 and found that our **RelWithDebInfo** CMake configurations were failing. This was due to the changes in `cmake/FindTBB.cmake` and output string that is ill configured. The error we get back from Clang is:
```
error: 'optimized;/path/to/install/lib64/libtbbmalloc.so.2;debug;/path/to/install/lib64/libtbbmalloc_debug.so.2', needed by 'src/some/library.so', missing and no known rule to make it.
```
It appears that instead of a specific library file being passed as IMPORTED_LOCATION when constructing the TBB CMake IMPORT target, we are instead passing a CMake string with both release and debug library locations. I believe these might be the key lines.
`cmake/FindTBB.cmake:288`:
```
set(Tbb_${COMPONENT}_LIBRARY optimized ${Tbb_${COMPONENT}_LIBRARY_RELEASE} debug ${Tbb_${COMPONENT}_LIBRARY_DEBUG})
```
`cmake/FindTBB.cmake:418`:
```
set_target_properties(TBB::${COMPONENT} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${Tbb_${COMPONENT}_LIBRARY}")
```
My expectation when building a CMake **RelWithDebInfo** configuration is that my library will be linked against the debug build of TBB, rather than a release build. But release would also not be an issue. As long as one is selected and the build works.
### To Reproduce
Steps to reproduce the behavior:
1. Checkout repo '...'
2. Run CMake with `-D CMAKE_BUILD_TYPE=RelWithDebInfo`
3. Build binary
### Additional context
Our downstream project sets the CMAKE_MODULE_PATH to that of the modules included with OpenVDB. As a result we pick up the FindTBB.cmake module. We might be better off with a CMake config if one was installed along with the OpenVDB binary, avoiding this need. It looks like there is already a ticket for this https://github.com/AcademySoftwareFoundation/openvdb/issues/1160
Contributor guide
Research direction
Start with cmake/FindTBB.cmake, especially lines 288 and 418, and reproduce the failure with CMAKE_BUILD_TYPE=RelWithDebInfo. Verify that the TBB imported target receives a valid library path and that the downstream build completes without the missing-rule error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100