Browse Source

Moved the definition of _HAS_EXCEPTIONS from cmake to Core.h (#1635)

This allows compiling Jolt in the context of an Unreal Engine plugin.

See #1634
Jorrit Rouwe 3 months ago
parent
commit
4c962c4f85
2 changed files with 5 additions and 5 deletions
  1. 5 0
      Jolt/Core/Core.h
  2. 0 5
      Jolt/Jolt.cmake

+ 5 - 0
Jolt/Core/Core.h

@@ -437,6 +437,11 @@
 #define JPH_SUPPRESS_WARNINGS_STD_END															\
 	JPH_SUPPRESS_WARNING_POP
 
+// MSVC STL requires _HAS_EXCEPTIONS=0 if exceptions are turned off
+#if defined(JPH_COMPILER_MSVC) && (!defined(__cpp_exceptions) || !__cpp_exceptions) && !defined(_HAS_EXCEPTIONS)
+	#define _HAS_EXCEPTIONS 0
+#endif
+
 // Standard C++ includes
 JPH_SUPPRESS_WARNINGS_STD_BEGIN
 #include <float.h>

+ 0 - 5
Jolt/Jolt.cmake

@@ -511,11 +511,6 @@ else()
 	target_precompile_headers(Jolt PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
 endif()
 
-if (NOT CPP_EXCEPTIONS_ENABLED)
-	# Disable use of exceptions in MSVC's STL
-	target_compile_definitions(Jolt PUBLIC $<$<BOOL:${MSVC}>:_HAS_EXCEPTIONS=0>)
-endif()
-
 # Set the debug/non-debug build flags
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Debug>:_DEBUG>")
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Release,Distribution,ReleaseASAN,ReleaseUBSAN,ReleaseTSAN,ReleaseCoverage>:NDEBUG>")