From 43c8db3c9fdd92d847cf69eec14358b0408e8c34 Mon Sep 17 00:00:00 2001 From: Walter Pearce Date: Thu, 30 Nov 2017 15:38:49 -0800 Subject: [PATCH] Fixed: Debug/CHECK builds of bgfx were not straightforward with the current setup; bgfx relies on BX also being debug-enabled, while this only enabled it for BGFX and only in CMAKE Debug mode. Added BGFX_CONFIG_DEBUG cmake option to easily enable checked/trace builds in release mode --- CMakeLists.txt | 1 + cmake/bgfx.cmake | 3 +++ cmake/bx.cmake | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea83734..8b75a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON option( BGFX_USE_OVR "Build with OVR support." OFF ) option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF ) option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF ) +option( BGFX_CONFIG_DEBUG "Enables debug configuration on all builds" OFF) if( NOT BX_DIR ) set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." ) diff --git a/cmake/bgfx.cmake b/cmake/bgfx.cmake index 2ae4a5c..bc51838 100755 --- a/cmake/bgfx.cmake +++ b/cmake/bgfx.cmake @@ -35,6 +35,9 @@ add_library( bgfx STATIC ${BGFX_SOURCES} ) # Enable BGFX_CONFIG_DEBUG in Debug configuration target_compile_definitions( bgfx PRIVATE "$<$:BGFX_CONFIG_DEBUG=1>" ) +if(BGFX_CONFIG_DEBUG) + target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_DEBUG=1) +endif() # Special Visual Studio Flags if( MSVC ) diff --git a/cmake/bx.cmake b/cmake/bx.cmake index 257880c..17d2ad0 100644 --- a/cmake/bx.cmake +++ b/cmake/bx.cmake @@ -16,6 +16,7 @@ endif() # Grab the bx source files file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp ) + if(BX_AMALGAMATED) set(BX_NOBUILD ${BX_SOURCES}) list(REMOVE_ITEM BX_NOBUILD ${BX_DIR}/src/amalgamated.cpp) @@ -51,6 +52,11 @@ target_compile_definitions( bx PUBLIC "__STDC_LIMIT_MACROS" ) target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" ) target_compile_definitions( bx PUBLIC "__STDC_CONSTANT_MACROS" ) +target_compile_definitions( bx PRIVATE "$<$:BX_CONFIG_DEBUG=1>" ) +if(BGFX_CONFIG_DEBUG) + target_compile_definitions( bx PRIVATE BX_CONFIG_DEBUG=1) +endif() + # Additional dependencies on Unix if( UNIX AND NOT APPLE ) # Threads