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 install(TARGETS ${target} 27 EXPORT TBBTargets 28 LIBRARY 29 DESTINATION ${CMAKE_INSTALL_LIBDIR} 30 NAMELINK_SKIP 31 COMPONENT runtime 32 RUNTIME 33 DESTINATION ${CMAKE_INSTALL_BINDIR} 34 COMPONENT runtime 35 ARCHIVE 36 DESTINATION ${CMAKE_INSTALL_LIBDIR} 37 COMPONENT devel) 38 39 if (BUILD_SHARED_LIBS) 40 install(TARGETS ${target} 41 LIBRARY 42 DESTINATION ${CMAKE_INSTALL_LIBDIR} 43 NAMELINK_ONLY 44 COMPONENT devel) 45 endif() 46 if (MSVC AND BUILD_SHARED_LIBS) 47 install(FILES $<TARGET_PDB_FILE:${target}> 48 DESTINATION ${CMAKE_INSTALL_BINDIR} 49 COMPONENT devel 50 OPTIONAL) 51 endif() 52endmacro() 53 54macro(tbb_handle_ipo target) 55 if (TBB_IPO_PROPERTY) 56 set_target_properties(${target} PROPERTIES 57 INTERPROCEDURAL_OPTIMIZATION TRUE 58 INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE 59 ) 60 elseif (TBB_IPO_FLAGS) 61 target_compile_options(${target} PRIVATE ${TBB_IPO_COMPILE_FLAGS}) 62 if (COMMAND target_link_options) 63 target_link_options(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) 64 else() 65 target_link_libraries(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) 66 endif() 67 endif() 68endmacro() 69