Merge pull request #20940 from alalek:cmake_fix_samples_parallel_backend

This commit is contained in:
Alexander Alekhin 2021-10-25 18:17:13 +00:00
commit 017a4e7c30
2 changed files with 33 additions and 20 deletions

View File

@ -72,6 +72,8 @@ include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONA
if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.1")
add_subdirectory("example_cmake")
endif()
if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.9")
if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.9"
AND NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND
)
add_subdirectory("tutorial_code/core/parallel_backend")
endif()

View File

@ -2,25 +2,36 @@ cmake_minimum_required(VERSION 3.9)
find_package(OpenCV REQUIRED COMPONENTS opencv_core)
find_package(OpenMP)
if(OpenMP_FOUND)
project(opencv_example_openmp_backend)
add_executable(opencv_example_openmp_backend example-openmp.cpp)
target_link_libraries(opencv_example_openmp_backend PRIVATE
opencv_core
OpenMP::OpenMP_CXX
)
if(NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND_OPENMP
AND NOT OPENCV_EXAMPLES_SKIP_OPENMP
)
find_package(OpenMP)
if(OpenMP_FOUND)
project(opencv_example_openmp_backend)
add_executable(opencv_example_openmp_backend example-openmp.cpp)
target_link_libraries(opencv_example_openmp_backend PRIVATE
opencv_core
OpenMP::OpenMP_CXX
)
endif()
endif()
# TODO: find_package(TBB)
find_path(TBB_INCLUDE_DIR NAMES "tbb/tbb.h")
find_library(TBB_LIBRARY NAMES "tbb")
if(TBB_INCLUDE_DIR AND TBB_LIBRARY AND NOT OPENCV_EXAMPLE_SKIP_TBB)
project(opencv_example_tbb_backend)
add_executable(opencv_example_tbb_backend example-tbb.cpp)
target_include_directories(opencv_example_tbb_backend SYSTEM PRIVATE ${TBB_INCLUDE_DIR})
target_link_libraries(opencv_example_tbb_backend PRIVATE
opencv_core
${TBB_LIBRARY}
)
if(NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND_TBB
AND NOT OPENCV_EXAMPLES_SKIP_TBB
AND NOT OPENCV_EXAMPLE_SKIP_TBB # deprecated (to be removed in OpenCV 5.0)
)
find_package(TBB)
if(NOT TBB_FOUND)
find_path(TBB_INCLUDE_DIR NAMES "tbb/tbb.h")
find_library(TBB_LIBRARY NAMES "tbb")
endif()
if(TBB_INCLUDE_DIR AND TBB_LIBRARY)
project(opencv_example_tbb_backend)
add_executable(opencv_example_tbb_backend example-tbb.cpp)
target_include_directories(opencv_example_tbb_backend SYSTEM PRIVATE ${TBB_INCLUDE_DIR})
target_link_libraries(opencv_example_tbb_backend PRIVATE
opencv_core
${TBB_LIBRARY}
)
endif()
endif()