cmake(tbb): fix target_compile_definitions() with "UNKNOWN" target
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 3 Feb 2021 22:16:42 +0000 (22:16 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 3 Feb 2021 22:18:39 +0000 (22:18 +0000)
- https://gitlab.kitware.com/cmake/cmake/-/issues/19434

cmake/OpenCVDetectTBB.cmake

index 794042f..cade0f8 100644 (file)
@@ -85,7 +85,11 @@ function(ocv_tbb_env_guess _found)
     if(NOT (TBB_INTERFACE_VERSION LESS 12000))  # >= 12000, oneTBB 2021+
       # avoid "defaultlib" requirement of tbb12.lib (we are using absolute path to 'tbb.lib' only)
       # https://github.com/oneapi-src/oneTBB/blame/2dba2072869a189b9fdab3ffa431d3ea49059a19/include/oneapi/tbb/detail/_config.h#L334
-      target_compile_definitions(tbb INTERFACE "__TBB_NO_IMPLICIT_LINKAGE=1")
+      if(NOT (CMAKE_VERSION VERSION_LESS "3.16.0"))  # https://gitlab.kitware.com/cmake/cmake/-/issues/19434
+        target_compile_definitions(tbb INTERFACE "__TBB_NO_IMPLICIT_LINKAGE=1")
+      else()
+        set_target_properties(tbb PROPERTIES INTERFACE_COMPILE_OPTIONS "__TBB_NO_IMPLICIT_LINKAGE=1")
+      endif()
     endif()
     message(STATUS "Found TBB (env): ${TBB_ENV_LIB}")
     set(${_found} TRUE PARENT_SCOPE)