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 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 ${TBB_COMMON_COMPILE_FLAGS} /volatile:iso /FS /EHsc) 37 38set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /DYNAMICBASE /NXCOMPAT) 39 40if (TBB_ARCH EQUAL 32) 41 set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /SAFESEH ) 42endif() 43 44# Ignore /WX set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled. 45if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag) 46 tbb_remove_compile_flag(/WX) 47endif() 48 49if (WINDOWS_STORE OR TBB_WINDOWS_DRIVER) 50 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D_WIN32_WINNT=0x0A00) 51 set(TBB_COMMON_LINK_FLAGS -NODEFAULTLIB:kernel32.lib -INCREMENTAL:NO) 52 set(TBB_COMMON_LINK_LIBS OneCore.lib) 53endif() 54 55if (WINDOWS_STORE) 56 if (NOT CMAKE_SYSTEM_VERSION EQUAL 10.0) 57 message(FATAL_ERROR "CMAKE_SYSTEM_VERSION must be equal to 10.0") 58 endif() 59 60 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /ZW /ZW:nostdlib) 61 62 # CMake define this extra lib, remove it for this build type 63 string(REGEX REPLACE "WindowsApp.lib" "" CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}") 64 65 if (TBB_NO_APPCONTAINER) 66 set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -APPCONTAINER:NO) 67 endif() 68endif() 69 70if (TBB_WINDOWS_DRIVER) 71 # Since this is universal driver disable this variable 72 set(CMAKE_SYSTEM_PROCESSOR "") 73 74 # CMake define list additional libs, remove it for this build type 75 set(CMAKE_CXX_STANDARD_LIBRARIES "") 76 77 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D _UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__) 78endif() 79 80if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)") 81 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)") 82 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm -mwaitpkg) 83 endif() 84 set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) 85 set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) 86else() 87 set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/GL>) 88 set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-LTCG> $<$<NOT:$<CONFIG:Debug>>:-INCREMENTAL:NO>) 89endif() 90 91set(TBB_OPENMP_FLAG /openmp) 92set(TBB_OPENMP_NO_LINK_FLAG TRUE) # TBB_OPENMP_FLAG will be used only on compilation but not on linkage 93