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 15add_library(tbbmalloc_proxy 16 function_replacement.cpp 17 proxy.cpp) 18 19add_library(TBB::tbbmalloc_proxy ALIAS tbbmalloc_proxy) 20 21target_compile_definitions(tbbmalloc_proxy 22 PUBLIC 23 $<$<CONFIG:DEBUG>:TBB_USE_DEBUG> 24 PRIVATE 25 __TBBMALLOCPROXY_BUILD) 26 27target_include_directories(tbbmalloc_proxy 28 PUBLIC 29 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include> 30 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) 31 32if (NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 33 # gcc 5.0 and later have -Wno-sized-deallocation options 34 set(TBB_WARNING_SUPPRESS ${TBB_WARNING_SUPPRESS} 35 $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},5.0>>:-Wno-sized-deallocation>) 36endif() 37 38target_compile_options(tbbmalloc_proxy 39 PRIVATE 40 ${TBB_CXX_STD_FLAG} # TODO: consider making it PUBLIC. 41 ${TBB_MMD_FLAG} 42 ${TBB_DSE_FLAG} 43 ${TBB_WARNING_LEVEL} 44 ${TBB_WARNING_SUPPRESS} 45 ${TBB_LIB_COMPILE_FLAGS} 46 ${TBB_COMMON_COMPILE_FLAGS} 47) 48 49set_target_properties(tbbmalloc_proxy PROPERTIES 50 VERSION ${TBBMALLOC_BINARY_VERSION}.${TBB_BINARY_MINOR_VERSION} 51 SOVERSION ${TBBMALLOC_BINARY_VERSION}) 52 53if (UNIX AND NOT APPLE) 54 # Avoid use of target_link_libraries here as it changes /DEF option to \DEF on Windows. 55 set_target_properties(tbbmalloc_proxy PROPERTIES 56 LINK_FLAGS ${TBB_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_SOURCE_DIR}/def/${TBB_DEF_FILE_PREFIX}-proxy.def 57 LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/def/${TBB_DEF_FILE_PREFIX}-proxy.def 58 DEFINE_SYMBOL "") 59endif() 60 61# Prefer using target_link_options instead of target_link_libraries to specify link options because 62# target_link_libraries may incorrectly handle some options (on Windows, for example). 63if (COMMAND target_link_options) 64 target_link_options(tbbmalloc_proxy 65 PRIVATE 66 ${TBB_LIB_LINK_FLAGS} 67 ${TBB_COMMON_LINK_FLAGS} 68 ) 69else() 70 target_link_libraries(tbbmalloc_proxy 71 PRIVATE 72 ${TBB_LIB_LINK_FLAGS} 73 ${TBB_COMMON_LINK_FLAGS} 74 ) 75endif() 76 77target_link_libraries(tbbmalloc_proxy 78 PRIVATE 79 TBB::tbbmalloc 80 Threads::Threads 81 ${TBB_LIB_LINK_LIBS} 82 ${TBB_COMMON_LINK_LIBS} 83) 84 85tbb_install_target(tbbmalloc_proxy) 86