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 15set(TBB_LINK_DEF_FILE_FLAG ${CMAKE_LINK_DEF_FILE_FLAG}) 16set(TBB_DEF_FILE_PREFIX win${TBB_ARCH}) 17 18# Workaround for CMake issue https://gitlab.kitware.com/cmake/cmake/issues/18317. 19# TODO: consider use of CMP0092 CMake policy. 20string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 21 22set(TBB_WARNING_LEVEL $<$<NOT:$<CXX_COMPILER_ID:Intel>>:/W4> $<$<BOOL:${TBB_STRICT}>:/WX>) 23 24# Warning suppression C4324: structure was padded due to alignment specifier 25set(TBB_WARNING_SUPPRESS /wd4324) 26 27set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} /bigobj) 28if (MSVC_VERSION LESS_EQUAL 1900) 29 # Warning suppression C4503 for VS2015 and earlier: 30 # decorated name length exceeded, name was truncated. 31 # More info can be found at 32 # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4503 33 set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} /wd4503) 34endif() 35set(TBB_LIB_COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS /GS) 36set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS /EHsc) 37 38# Ignore /WX set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled. 39if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag) 40 tbb_remove_compile_flag(/WX) 41endif() 42 43if (WINDOWS_STORE OR TBB_WINDOWS_DRIVER) 44 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D_WIN32_WINNT=0x0A00) 45 set(TBB_COMMON_LINK_FLAGS -NODEFAULTLIB:kernel32.lib -INCREMENTAL:NO) 46 set(TBB_COMMON_LINK_LIBS OneCore.lib) 47endif() 48 49if (WINDOWS_STORE) 50 if (NOT CMAKE_SYSTEM_VERSION EQUAL 10.0) 51 message(FATAL_ERROR "CMAKE_SYSTEM_VERSION must be equal to 10.0") 52 endif() 53 54 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /ZW /ZW:nostdlib) 55 56 # CMake define this extra lib, remove it for this build type 57 string(REGEX REPLACE "WindowsApp.lib" "" CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}") 58 59 if (TBB_NO_APPCONTAINER) 60 set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -APPCONTAINER:NO) 61 endif() 62endif() 63 64if (TBB_WINDOWS_DRIVER) 65 # Since this is universal driver disable this variable 66 set(CMAKE_SYSTEM_PROCESSOR "") 67 68 # CMake define list additional libs, remove it for this build type 69 set(CMAKE_CXX_STANDARD_LIBRARIES "") 70 71 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D _UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__) 72endif() 73 74if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)") 75 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)") 76 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm -mwaitpkg) 77 endif() 78 set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) 79 set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) 80else() 81 set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/GL>) 82 set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-LTCG> $<$<NOT:$<CONFIG:Debug>>:-INCREMENTAL:NO>) 83endif() 84 85set(TBB_OPENMP_FLAG /openmp) 86set(TBB_OPENMP_NO_LINK_FLAG TRUE) # TBB_OPENMP_FLAG will be used only on compilation but not on linkage 87