mirror of
https://github.com/uxlfoundation/oneDNN.git
synced 2025-10-20 18:43:49 +08:00
cmake: add standard c++ exception handling on Windows
This commit is contained in:
@ -84,10 +84,10 @@ if(UNIX)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
append(ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /DYNAMICBASE /sdl")
|
||||
append(ONEDNN_SDL_COMPILER_FLAGS "/EHsr /GS /Gy /guard:cf /DYNAMICBASE /sdl")
|
||||
append(ONEDNN_SDL_LINKER_FLAGS "/NXCOMPAT /LTCG")
|
||||
elseif(CMAKE_BASE_NAME STREQUAL "icx")
|
||||
append(ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /Wformat /Wformat-security")
|
||||
append(ONEDNN_SDL_COMPILER_FLAGS "/EHs /GS /Gy /guard:cf /Wformat /Wformat-security")
|
||||
append(ONEDNN_SDL_LINKER_FLAGS "/link /NXCOMPAT")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
append(ONEDNN_SDL_COMPILER_FLAGS "-Wformat -Wformat-security")
|
||||
|
@ -31,16 +31,14 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "oneapi/dnnl/dnnl_common.h"
|
||||
|
||||
/// @endcond
|
||||
|
||||
// __cpp_exceptions is referred from
|
||||
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html
|
||||
// gcc < 5 does not define __cpp_exceptions but __EXCEPTIONS,
|
||||
// Microsoft C++ Compiler does not provide an option to disable exceptions
|
||||
// If exceptions are enabled:
|
||||
// - gcc < 5 only define __EXCEPTIONS
|
||||
// - MSVC and Clang only define __cpp_exceptions
|
||||
// - new gcc and icx/icpx define both
|
||||
#ifndef DNNL_ENABLE_EXCEPTIONS
|
||||
#if __cpp_exceptions || __EXCEPTIONS \
|
||||
|| (defined(_MSC_VER) && !defined(__clang__))
|
||||
#if defined(__EXCEPTIONS) || defined(__cpp_exceptions)
|
||||
#define DNNL_ENABLE_EXCEPTIONS 1
|
||||
#else
|
||||
#define DNNL_ENABLE_EXCEPTIONS 0
|
||||
|
Reference in New Issue
Block a user