From 100db3dccc393dba48fae08dc2ea191015cf4195 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 27 Mar 2022 19:39:57 -0300 Subject: [PATCH] Add OGRE_EMBED_DEBUG_MODE CMake option Default is 'auto' which embeds the debug mode when using Make & Ninja, but doesn't when using XCode & MSVC. It also supports options "never" and "always" --- CMake/ConfigureBuild.cmake | 12 ++++++++++++ CMake/Templates/OgreBuildSettings.h.in | 4 ++++ CMakeLists.txt | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/CMake/ConfigureBuild.cmake b/CMake/ConfigureBuild.cmake index fdbfc8bcddd..3c1a1c129ae 100644 --- a/CMake/ConfigureBuild.cmake +++ b/CMake/ConfigureBuild.cmake @@ -99,6 +99,18 @@ set(OGRE_SET_USE_SIMD 0) set(OGRE_SET_RESTRICT_ALIASING 0) set(OGRE_SET_IDSTRING_ALWAYS_READABLE 0) set(OGRE_SET_DISABLE_AMD_AGS 0) +if((OGRE_EMBED_DEBUG_MODE STREQUAL "auto" AND + (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + OR OGRE_EMBED_DEBUG_MODE STREQUAL "always") + set( OGRE_SET_EMBED_DEBUG_MODE 1 ) + if( OGRE_BUILD_TYPE STREQUAL "debug" ) + set( OGRE_SET_DEBUG_MODE "OGRE_DEBUG_LEVEL_DEBUG" ) + else() + set( OGRE_SET_DEBUG_MODE "OGRE_DEBUG_LEVEL_RELEASE" ) + endif() +else() + set( OGRE_SET_EMBED_DEBUG_MODE 0 ) +endif() if (OGRE_CONFIG_DOUBLE) set(OGRE_SET_DOUBLE 1) endif() diff --git a/CMake/Templates/OgreBuildSettings.h.in b/CMake/Templates/OgreBuildSettings.h.in index c00c3b78ddd..01df9b5e7df 100644 --- a/CMake/Templates/OgreBuildSettings.h.in +++ b/CMake/Templates/OgreBuildSettings.h.in @@ -7,6 +7,10 @@ #define OGRE_DEBUG_LEVEL_DEBUG @OGRE_DEBUG_LEVEL_DEBUG@ #define OGRE_DEBUG_LEVEL_RELEASE @OGRE_DEBUG_LEVEL_RELEASE@ +#if @OGRE_SET_EMBED_DEBUG_MODE@ +# define OGRE_DEBUG_MODE @OGRE_SET_DEBUG_MODE@ +#endif + #cmakedefine OGRE_BUILD_RENDERSYSTEM_D3D11 #cmakedefine OGRE_BUILD_RENDERSYSTEM_GL3PLUS #cmakedefine OGRE_BUILD_RENDERSYSTEM_GLES diff --git a/CMakeLists.txt b/CMakeLists.txt index 89dcdb4ad8a..c4abe642874 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,6 +491,12 @@ set(OGRE_CONFIG_ALLOCATOR 0 CACHE STRING ) endif () +set( OGRE_EMBED_DEBUG_MODE auto CACHE STRING + "Specify whether OGRE_DEBUG_MODE should be embedded into OgreBuildSettings.h + auto - Use 'never' for multi-config generators like MSVC & XCode. Use 'always' for Make & Ninja generators + never - Compile headers will determine whether it's a debug build based on macros like _DEBUG, DEBUG & NDEBUG + always - OGRE_DEBUG_MODE is embedded into OgreBuildSettings.h, its value is based on CMAKE_BUILD_TYPE" +) set( OGRE_DEBUG_LEVEL_DEBUG 3 CACHE STRING "Specify debug level for debug builds: 0 - None. Disabled. No checks done at all.