From a17c0d628d70b8aa0a6d81760770f72808740e2c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 24 Jul 2019 10:35:36 +0200 Subject: [PATCH] Fix our usage of TBB and A lot of parts of CGAL use `` in conjunction with TBB. I have added the `find_package(Threads)` in `CGAL_target_use_TBB.cmake` for convenience. I have also restored FindTBB.cmake as a pure copy of https://github.com/Kitware/VTK/blob/master/CMake/FindTBB.cmake with that version: > c7249fed2e73ce25fbbc53363d9caf4ab5cc9195 > Author: Cory Quammen > Date: Thu Feb 14 23:21:09 2019 -0500 > > FindTBB: handle basic linker scripts > > TBB binaries may define libtbb.so as a linker script of the form > > INPUT(libtbb.so.2) > > Make FindTBB find the real .so file libtbb.so points to in such cases. > > Approach borrowed from vtk-m/CMake/VTKmDeviceAdapters.cmake on > suggestion from Robert Maynard. > > --- Installation/cmake/modules/CGAL_Common.cmake | 3 ++- Installation/cmake/modules/CGAL_target_use_TBB.cmake | 6 ++++-- Installation/cmake/modules/FindTBB.cmake | 3 --- Installation/lib/cmake/CGAL/CGALConfig.cmake | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Installation/cmake/modules/CGAL_Common.cmake b/Installation/cmake/modules/CGAL_Common.cmake index 9ade617f663..59f8190136d 100644 --- a/Installation/cmake/modules/CGAL_Common.cmake +++ b/Installation/cmake/modules/CGAL_Common.cmake @@ -61,5 +61,6 @@ if( NOT CGAL_COMMON_FILE_INCLUDED ) # set use-file for Eigen3 (needed to have default solvers) set(EIGEN3_USE_FILE "UseEigen3") - + set(TBB_USE_FILE "UseTBB") + include(${CMAKE_CURRENT_LIST_DIR}/CGAL_target_use_TBB.cmake) endif() diff --git a/Installation/cmake/modules/CGAL_target_use_TBB.cmake b/Installation/cmake/modules/CGAL_target_use_TBB.cmake index 23e9acd72f1..631ece6a286 100644 --- a/Installation/cmake/modules/CGAL_target_use_TBB.cmake +++ b/Installation/cmake/modules/CGAL_target_use_TBB.cmake @@ -4,7 +4,9 @@ endif() set(CGAL_target_use_TBB_included TRUE) function(CGAL_target_use_TBB target) - target_include_directories ( ${target} SYSTEM PUBLIC ${TBB_INCLUDE_DIRS} ) - target_link_libraries( ${target} PUBLIC ${TBB_LIBRARIES} ) + if(NOT TARGET Threads::Threads) + find_package(Threads REQUIRED) + endif() + target_link_libraries( ${target} PUBLIC TBB::tbb TBB::tbbmalloc Threads::Threads) target_compile_options( ${target} PUBLIC -DNOMINMAX -DCGAL_LINKED_WITH_TBB ) endfunction() diff --git a/Installation/cmake/modules/FindTBB.cmake b/Installation/cmake/modules/FindTBB.cmake index 5e7dc208df8..b1a3d884c65 100644 --- a/Installation/cmake/modules/FindTBB.cmake +++ b/Installation/cmake/modules/FindTBB.cmake @@ -419,6 +419,3 @@ if(NOT TBB_VERSION) TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") endif() - -set(TBB_USE_FILE "UseTBB") -include(${CMAKE_CURRENT_LIST_DIR}/CGAL_target_use_TBB.cmake) diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index c2b0aed549d..630117e24ad 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -140,6 +140,8 @@ include(${CGAL_MODULES_DIR}/CGAL_TweakFindBoost.cmake) cgal_setup_module_path() set(CGAL_USE_FILE ${CGAL_MODULES_DIR}/UseCGAL.cmake) +set(TBB_USE_FILE "UseTBB") +include(${CMAKE_CURRENT_LIST_DIR}/CGAL_target_use_TBB.cmake) include("${CGAL_MODULES_DIR}/CGAL_parse_version_h.cmake") cgal_parse_version_h( "${CGAL_INSTALLATION_PACKAGE_DIR}/include/CGAL/version.h"