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 15macro(set_common_project_settings required_components) 16 # Path to common headers 17 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../) 18 19 if (NOT TARGET TBB::tbb) 20 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../common/cmake/modules) 21 find_package(TBB REQUIRED COMPONENTS ${required_components}) 22 endif() 23 find_package(Threads REQUIRED) 24 25 # --------------------------------------------------------------------------------------------------------- 26 # Handle C++ standard version. 27 if (NOT MSVC) # no need to cover MSVC as it uses C++14 by default. 28 if (NOT CMAKE_CXX_STANDARD) 29 set(CMAKE_CXX_STANDARD 11) 30 endif() 31 if (CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION) # if standard option was detected by CMake 32 set(CMAKE_CXX_STANDARD_REQUIRED ON) 33 endif() 34 endif() 35 36 set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++... instead of -std=gnu++... 37 # --------------------------------------------------------------------------------------------------------- 38endmacro() 39 40macro(add_execution_target TARGET_NAME TARGET_DEPENDENCIES EXECUTABLE ARGS) 41 if (WIN32) 42 add_custom_target(${TARGET_NAME} set "PATH=$<TARGET_FILE_DIR:TBB::tbb>\\;$ENV{PATH}" & ${EXECUTABLE} ${ARGS}) 43 else() 44 add_custom_target(${TARGET_NAME} ${EXECUTABLE} ${ARGS}) 45 endif() 46 47 add_dependencies(${TARGET_NAME} ${TARGET_DEPENDENCIES}) 48endmacro() 49