Skip to content

Commit

Permalink
Add OGRE_EMBED_DEBUG_MODE CMake option
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
darksylinc committed Mar 27, 2022
1 parent f9139d4 commit 100db3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMake/ConfigureBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions CMake/Templates/OgreBuildSettings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 100db3d

Please sign in to comment.