1# Copyright (c) 2020-2023 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 15macro(tbb_remove_compile_flag flag) 16 get_property(_tbb_compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS) 17 list(REMOVE_ITEM _tbb_compile_options ${flag}) 18 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS ${_tbb_compile_options}) 19 unset(_tbb_compile_options) 20 if (CMAKE_CXX_FLAGS) 21 string(REGEX REPLACE "(^|[ \t\r\n]+)${flag}($|[ \t\r\n]+)" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) 22 endif() 23endmacro() 24 25macro(tbb_install_target target) 26 if (TBB_INSTALL) 27 install(TARGETS ${target} 28 EXPORT TBBTargets 29 LIBRARY 30 DESTINATION ${CMAKE_INSTALL_LIBDIR} 31 NAMELINK_SKIP 32 COMPONENT runtime 33 RUNTIME 34 DESTINATION ${CMAKE_INSTALL_BINDIR} 35 COMPONENT runtime 36 ARCHIVE 37 DESTINATION ${CMAKE_INSTALL_LIBDIR} 38 COMPONENT devel) 39 40 if (BUILD_SHARED_LIBS) 41 install(TARGETS ${target} 42 LIBRARY 43 DESTINATION ${CMAKE_INSTALL_LIBDIR} 44 NAMELINK_ONLY 45 COMPONENT devel) 46 endif() 47 if (MSVC AND BUILD_SHARED_LIBS) 48 install(FILES $<TARGET_PDB_FILE:${target}> 49 DESTINATION ${CMAKE_INSTALL_BINDIR} 50 COMPONENT devel 51 OPTIONAL) 52 endif() 53 endif() 54endmacro() 55 56macro(tbb_handle_ipo target) 57 if (TBB_IPO_PROPERTY) 58 set_target_properties(${target} PROPERTIES 59 INTERPROCEDURAL_OPTIMIZATION TRUE 60 INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE 61 ) 62 elseif (TBB_IPO_FLAGS) 63 target_compile_options(${target} PRIVATE ${TBB_IPO_COMPILE_FLAGS}) 64 if (COMMAND target_link_options) 65 target_link_options(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) 66 else() 67 target_link_libraries(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) 68 endif() 69 endif() 70endmacro() 71