Skip to content

Commit 97cda25

Browse files
committed
build: tweak for portability with exceptions
Teach the build system how to spell `-fno-exceptions` in a foreign grammar. This allows building with `clang-cl` without a warning for the invalid argument. The spelling is documented at https://learn.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=msvc-170
1 parent a239222 commit 97cda25

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/_TestingInternals/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ add_library(_TestingInternals STATIC
1717
WillThrow.cpp)
1818
target_include_directories(_TestingInternals PUBLIC
1919
${CMAKE_CURRENT_SOURCE_DIR}/include)
20-
target_compile_options(_TestingInternals PRIVATE
21-
-fno-exceptions)
20+
if("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" OR
21+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
22+
target_compile_options(_TestingInternals PRIVATE
23+
/EHa-c)
24+
else()
25+
target_compile_options(_TestingInternals PRIVATE
26+
-fno-exceptions)
27+
endif()
2228

2329
if(NOT BUILD_SHARED_LIBS)
2430
# When building a static library, install the internal library archive

0 commit comments

Comments
 (0)