Fixes: Sets _HAS_EXCEPTIONS=0 globally #701 (#707)

This makes the `_HAS_EXCEPTIONS` flag on windows only apply to libraries, and not if the library is used header only.
This commit is contained in:
Matthew Parkinson
2024-12-12 09:36:12 +00:00
committed by GitHub
parent 35cda3d1fd
commit f57e27de19

View File

@@ -293,9 +293,7 @@ if(${Backtrace_FOUND})
$<${ci_or_debug}:${Backtrace_INCLUDE_DIRS}>)
endif()
if(MSVC)
target_compile_definitions(snmalloc INTERFACE -D_HAS_EXCEPTIONS=0)
else()
if(NOT MSVC)
check_linker_flag(CXX "-rdynamic" SNMALLOC_LINKER_SUPPORT_RDYNAMIC)
if (SNMALLOC_LINKER_SUPPORT_RDYNAMIC)
# Get better stack traces in CI and debug builds.
@@ -429,6 +427,10 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET hidden INTERPROCEDURAL_OPTIMIZATION ${SNMALLOC_COMPILER_SUPPORT_IPO})
target_compile_definitions(${name} PRIVATE "SNMALLOC_USE_${SNMALLOC_CLEANUP}")
if(MSVC)
target_compile_definitions(${name} INTERFACE -D_HAS_EXCEPTIONS=0)
endif()
add_warning_flags(${name})
if(NOT MSVC)
target_compile_definitions(${name} PRIVATE "SNMALLOC_EXPORT=__attribute__((visibility(\"default\")))")