Browse Source

Added option to build debug build with release MSVC runtime libraries

Jorrit Rouwe 1 day ago
parent
commit
787e7ac78d
2 changed files with 5 additions and 5 deletions
  1. 4 3
      Build/CMakeLists.txt
  2. 1 2
      Jolt/Jolt.cmake

+ 4 - 3
Build/CMakeLists.txt

@@ -118,6 +118,9 @@ include(CMakeDependentOption)
 # Windows Store only supports the DLL version
 # Windows Store only supports the DLL version
 cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF)
 cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF)
 
 
+# Ability to always use the release MSVC runtime library even in Debug mode
+option(JPH_USE_RELEASE_MSVC_RUNTIME_LIBRARY "Use the release MSVC runtime library even in Debug mode" OFF)
+
 # Enable Vulkan instead of DirectX
 # Enable Vulkan instead of DirectX
 cmake_dependent_option(JPH_ENABLE_VULKAN "Enable Vulkan" ON "LINUX" OFF)
 cmake_dependent_option(JPH_ENABLE_VULKAN "Enable Vulkan" ON "LINUX" OFF)
 
 
@@ -138,9 +141,7 @@ if (MSVC)
 	set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
 	set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
 
 
 	# Set runtime library
 	# Set runtime library
-	if (USE_STATIC_MSVC_RUNTIME_LIBRARY)
-		set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
-	endif()
+	set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<IF:$<BOOL:${JPH_USE_RELEASE_MSVC_RUNTIME_LIBRARY}>,,$<$<CONFIG:Debug>:Debug>>$<IF:$<BOOL:${USE_STATIC_MSVC_RUNTIME_LIBRARY}>,,DLL>")
 
 
 	# Set general compiler flags
 	# Set general compiler flags
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline")

+ 1 - 2
Jolt/Jolt.cmake

@@ -511,8 +511,7 @@ else()
 	target_precompile_headers(Jolt PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
 	target_precompile_headers(Jolt PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
 endif()
 endif()
 
 
-# Set the debug/non-debug build flags
-target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Debug>:_DEBUG>")
+# Set the NDEBUG define for release builds
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Release,Distribution,ReleaseASAN,ReleaseUBSAN,ReleaseTSAN,ReleaseCoverage>:NDEBUG>")
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Release,Distribution,ReleaseASAN,ReleaseUBSAN,ReleaseTSAN,ReleaseCoverage>:NDEBUG>")
 
 
 # ASAN and TSAN should use the default allocators
 # ASAN and TSAN should use the default allocators