Skip to content

Commit 100db3d

Browse files
committed
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"
1 parent f9139d4 commit 100db3d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CMake/ConfigureBuild.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ set(OGRE_SET_USE_SIMD 0)
9999
set(OGRE_SET_RESTRICT_ALIASING 0)
100100
set(OGRE_SET_IDSTRING_ALWAYS_READABLE 0)
101101
set(OGRE_SET_DISABLE_AMD_AGS 0)
102+
if((OGRE_EMBED_DEBUG_MODE STREQUAL "auto" AND
103+
(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
104+
OR OGRE_EMBED_DEBUG_MODE STREQUAL "always")
105+
set( OGRE_SET_EMBED_DEBUG_MODE 1 )
106+
if( OGRE_BUILD_TYPE STREQUAL "debug" )
107+
set( OGRE_SET_DEBUG_MODE "OGRE_DEBUG_LEVEL_DEBUG" )
108+
else()
109+
set( OGRE_SET_DEBUG_MODE "OGRE_DEBUG_LEVEL_RELEASE" )
110+
endif()
111+
else()
112+
set( OGRE_SET_EMBED_DEBUG_MODE 0 )
113+
endif()
102114
if (OGRE_CONFIG_DOUBLE)
103115
set(OGRE_SET_DOUBLE 1)
104116
endif()

CMake/Templates/OgreBuildSettings.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#define OGRE_DEBUG_LEVEL_DEBUG @OGRE_DEBUG_LEVEL_DEBUG@
88
#define OGRE_DEBUG_LEVEL_RELEASE @OGRE_DEBUG_LEVEL_RELEASE@
99

10+
#if @OGRE_SET_EMBED_DEBUG_MODE@
11+
# define OGRE_DEBUG_MODE @OGRE_SET_DEBUG_MODE@
12+
#endif
13+
1014
#cmakedefine OGRE_BUILD_RENDERSYSTEM_D3D11
1115
#cmakedefine OGRE_BUILD_RENDERSYSTEM_GL3PLUS
1216
#cmakedefine OGRE_BUILD_RENDERSYSTEM_GLES

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ set(OGRE_CONFIG_ALLOCATOR 0 CACHE STRING
491491
)
492492
endif ()
493493

494+
set( OGRE_EMBED_DEBUG_MODE auto CACHE STRING
495+
"Specify whether OGRE_DEBUG_MODE should be embedded into OgreBuildSettings.h
496+
auto - Use 'never' for multi-config generators like MSVC & XCode. Use 'always' for Make & Ninja generators
497+
never - Compile headers will determine whether it's a debug build based on macros like _DEBUG, DEBUG & NDEBUG
498+
always - OGRE_DEBUG_MODE is embedded into OgreBuildSettings.h, its value is based on CMAKE_BUILD_TYPE"
499+
)
494500
set( OGRE_DEBUG_LEVEL_DEBUG 3 CACHE STRING
495501
"Specify debug level for debug builds:
496502
0 - None. Disabled. No checks done at all.

0 commit comments

Comments
 (0)