2 # Sets the following variables:
3 # TBB_INCLUDE_DIRS - path to the TBB include directory
4 # TBB_LIBRARIES - path to the TBB libraries to be linked against
7 #########################################################################
8 # Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
29 MESSAGE(STATUS "Check for TBB ...")
33 SET(TBB_ROOT_DIR $ENV{TBB_ROOT_DIR})
36 LIST(APPEND CMAKE_PREFIX_PATH "${TBB_ROOT_DIR}")
39 FIND_PATH(TBB_INCLUDE_DIRS tbb/tbb.h PATH_SUFFIXES include)
42 SET(PLT_SUFFIX intel64)
47 include(CheckCXXSourceCompiles)
51 FOREACH(_PATH cc4.1.0_libc2.4_kernel2.6.16.21 gcc4.4 gcc4.1)
52 LIST(APPEND _PATH_SUFFIXES ${PLT_SUFFIX}/${_PATH})
56 FIND_LIBRARY(_tbb_library_tbb
58 PATH_SUFFIXES ${_PATH_SUFFIXES})
59 FIND_LIBRARY(_tbb_library_tbbmalloc
61 PATH_SUFFIXES ${_PATH_SUFFIXES})
63 SET(_tbb_libraries ${_tbb_library_tbb} ${_tbb_library_tbbmalloc})
67 SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
68 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
69 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${TBB_INCLUDE_DIRS}")
70 SET(CMAKE_REQUIRED_LIBRARIES "${_tbb_libraries}")
72 CHECK_CXX_SOURCE_COMPILES("
73 #include <tbb/parallel_for.h>
75 size_t testme(size_t n)
79 int main(int argc, char* argv[])
81 parallel_for<size_t>( 1, 10, 1, testme );
87 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
88 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
91 SET(TBB_LIBRARY_tbb ${_tbb_library_tbb} CACHE FILEPATH "Path to a library")
92 SET(TBB_LIBRARY_tbbmalloc ${_tbb_library_tbbmalloc} CACHE FILEPATH "Path to a library")
93 SET(TBB_LIBRARIES ${TBB_LIBRARY_tbb} ${TBB_LIBRARY_tbbmalloc})
98 INCLUDE(FindPackageHandleStandardArgs)
99 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARY_tbb TBB_LIBRARY_tbbmalloc)