1# Copyright (c) 2020-2021 Intel Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15include(${CMAKE_CURRENT_LIST_DIR}/../config_generation.cmake)
16
17# TBBConfig in TBB provided packages are expected to be placed into: <tbb-root>/lib/cmake/tbb*
18set(TBB_ROOT_REL_PATH "../../..")
19
20# Paths relative to TBB root directory
21set(INC_REL_PATH "include")
22set(LIB_REL_PATH "lib")
23set(DLL_REL_PATH "redist")
24
25# Parse version info
26file(READ ${CMAKE_CURRENT_LIST_DIR}/../../include/oneapi/tbb/version.h _tbb_version_info)
27string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_version_info}")
28string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_version_info}")
29string(REGEX REPLACE ".*#define TBB_VERSION_PATCH ([0-9]+).*" "\\1" _tbb_ver_patch "${_tbb_version_info}")
30string(REGEX REPLACE ".*#define __TBB_BINARY_VERSION ([0-9]+).*" "\\1" TBB_BINARY_VERSION "${_tbb_version_info}")
31file(READ ${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt _tbb_cmakelist)
32string(REGEX REPLACE ".*TBBMALLOC_BINARY_VERSION ([0-9]+).*" "\\1" TBBMALLOC_BINARY_VERSION "${_tbb_cmakelist}")
33set(TBBMALLOC_PROXY_BINARY_VERSION ${TBBMALLOC_BINARY_VERSION})
34string(REGEX REPLACE ".*TBBBIND_BINARY_VERSION ([0-9]+).*" "\\1" TBBBIND_BINARY_VERSION "${_tbb_cmakelist}")
35
36set(COMMON_ARGS
37    TBB_ROOT_REL_PATH ${TBB_ROOT_REL_PATH}
38    INC_REL_PATH ${INC_REL_PATH}
39    LIB_REL_PATH ${LIB_REL_PATH}
40    VERSION ${_tbb_ver_major}.${_tbb_ver_minor}.${_tbb_ver_patch}
41    TBB_BINARY_VERSION ${TBB_BINARY_VERSION}
42    TBBMALLOC_BINARY_VERSION ${TBBMALLOC_BINARY_VERSION}
43    TBBMALLOC_PROXY_BINARY_VERSION ${TBBMALLOC_PROXY_BINARY_VERSION}
44    TBBBIND_BINARY_VERSION ${TBBBIND_BINARY_VERSION}
45)
46
47tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/linux   SYSTEM_NAME Linux   HANDLE_SUBDIRS ${COMMON_ARGS})
48tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/windows SYSTEM_NAME Windows HANDLE_SUBDIRS DLL_REL_PATH ${DLL_REL_PATH} ${COMMON_ARGS})
49tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/darwin  SYSTEM_NAME Darwin  ${COMMON_ARGS})
50message(STATUS "TBBConfig files were created in ${INSTALL_DIR}")
51