diff options
author | timlyeee <43355299+timlyeee@users.noreply.github.com> | 2021-10-29 21:04:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 21:04:59 +0300 |
commit | e3a373f2b79997326cb9330d4f3192b9b5682966 (patch) | |
tree | 9a05b9d94b932370c14ef5f6125d489b715181b2 /CMakeLists.txt | |
parent | c194bb2a7ff2d0e3e6076965f7bdea37dc3dc54b (diff) |
Make cxx exceptions controllable (#4591)
* Make cxx exceptions controllable
Found a possible link error if we compile spirv-tools by using VS2019 and link with VS2017 for another project, unresolved symbols as _CxxFrameHandler4 and __GSHandlerCheck_EH4 will be thrown. As Visual Studio updated its c++ exceptions libs.
https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/
So we are making cxx exceptions controllable via a CMake option `ENABLE_EXCEPTIONS_ON_MSVC`.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 01e3b16f5..70caf857a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,7 @@ endif() # Note this target provides no API stability guarantees. # # Ideally, all of these will go away - see https://github.com/KhronosGroup/SPIRV-Tools/issues/3909. +option(ENABLE_EXCEPTIONS_ON_MSVC "Build SPIRV-TOOLS with c++ exceptions enabled in MSVC" ON) option(SPIRV_TOOLS_BUILD_STATIC "Build ${SPIRV_TOOLS}-static target. ${SPIRV_TOOLS} will alias to ${SPIRV_TOOLS}-static or ${SPIRV_TOOLS}-shared based on BUILD_SHARED_LIBS" ON) if(SPIRV_TOOLS_BUILD_STATIC) set(SPIRV_TOOLS_FULL_VISIBILITY ${SPIRV_TOOLS}-static) @@ -215,7 +216,9 @@ function(spvtools_default_compile_options TARGET) if (MSVC) # Specify /EHs for exception handling. This makes using SPIRV-Tools as # dependencies in other projects easier. - target_compile_options(${TARGET} PRIVATE /EHs) + if(ENABLE_EXCEPTIONS_ON_MSVC) + target_compile_options(${TARGET} PRIVATE /EHs) + endif() endif() # For MinGW cross compile, statically link to the C++ runtime. |