From ef16e4203ecb8ca789964163792f46a300933364 Mon Sep 17 00:00:00 2001 From: Manolis Stamatogiannakis Date: Fri, 12 Apr 2019 02:36:59 +0100 Subject: [PATCH] Fix compile error with external TBB and -DBUILD_SHARED_LIBS=OFF. Adds IMPORTED for the TBB::tbb alias target as otherwise cmake produces the following error: CMake Error: install(EXPORT "OpenCVModules" ...) includes target "opencv_core" which requires target "tbb" that is not in the export set. This problem occurs with the defaults used by homebrew on macOS, which compiles both static and shared versions of TBB and OpenCV. --- cmake/OpenCVDetectTBB.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVDetectTBB.cmake b/cmake/OpenCVDetectTBB.cmake index a9afe76950..403b446116 100644 --- a/cmake/OpenCVDetectTBB.cmake +++ b/cmake/OpenCVDetectTBB.cmake @@ -29,8 +29,10 @@ function(ocv_tbb_cmake_guess _found) message(STATUS "Found TBB (cmake): ${_lib}") get_target_property(_inc TBB::tbb INTERFACE_INCLUDE_DIRECTORIES) ocv_tbb_read_version("${_inc}") - add_library(tbb INTERFACE) - target_link_libraries(tbb INTERFACE TBB::tbb) + add_library(tbb INTERFACE IMPORTED) + set_target_properties(tbb PROPERTIES + INTERFACE_LINK_LIBRARIES TBB::tbb + ) set(${_found} TRUE PARENT_SCOPE) endif() endfunction()