From f57e27de19d76d825512bfc2f5da7a7f331d280e Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Thu, 12 Dec 2024 09:36:12 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68fc790..a71f378 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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\")))")