Repository: opencv
Issue: TBB not added to link line with Cmake and find_package( OpenCV)
Labels: priority: low,category: build/install,incomplete,category: 3rdparty

TBB not added to link line with Cmake and find_package( OpenCV).

I know it's possible to detect if OpenCV was compiled with TBB by using ldd or other OS-specific tool. What I am trying to do is stick within CMake and the official OpenCV Cmake files. I thought maybe there would be a component specifically for TBB so I tried adding that and still no luck.

Found OpenCV: /usr/local (found version "4.5.4") found components: core imgproc highgui tracking cudafeatures2d cudaoptflow cudaimgproc freetype missing components: tbb cudaobjdetect

The following link errors appear, when I would have expected "tbb" to be added to the link line as part of OpenCV_Libraries when Cmake found OpenCV.

```
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::internal_set_capacity(long, unsigned long)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::NFS_Free(void*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::internal_finish_clear()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::~concurrent_queue_base_v3()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::task::note_affinity(unsigned short)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::interface7::internal::task_arena_base::internal_current_slot()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::internal_pop_if_present(void*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::concurrent_queue_base_v3(unsigned long)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `typeinfo for tbb::task'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::task_group_context::init()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::task_group_context::~task_group_context()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::internal_push(void const*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::throw_exception_v4(tbb::internal::exception_id)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `typeinfo for tbb::internal::concurrent_queue_base_v3'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::internal_pop(void*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_gapi.so.4.5.4: undefined reference to `tbb::internal::concurrent_queue_base_v3::assign(tbb::internal::concurrent_queue_base_v3 const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libopencv_core.so.4.5.4: undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
```

##### System information (version)
- OpenCV => 4.5.4
- Operating System / Platform => Windows/Linux
- Compiler => GCC/MinGW
##### Detailed description

When using Cmake to add OpenCV to a C++ project it omits whether OpenCV was built with TBB.

##### Steps to reproduce

Use CMake to detect OpenCV.
Build then fails because OpenCV requires TBB on the link line but it's CMake files as installed did not request it.

##### Issue submission checklist

 - [x] I report the issue, it's not a question

 - [x] I checked the problem with documentation, FAQ, open issues,

 - [x] I updated to latest OpenCV version and the issue is still there

 - [x] There is reproducer code and related data files: videos, images, onnx, etc