diff --git a/redGrapes/memory/chunked_bump_alloc.hpp b/redGrapes/memory/chunked_bump_alloc.hpp index ed458116..5b813453 100644 --- a/redGrapes/memory/chunked_bump_alloc.hpp +++ b/redGrapes/memory/chunked_bump_alloc.hpp @@ -25,7 +25,7 @@ #include #include -#ifndef NDEBUG +#if REDGRAPES_ENABLE_BACKWARDCPP #include #endif @@ -150,7 +150,7 @@ struct ChunkedBumpAlloc prev = it; } -#ifndef NDEBUG +#if REDGRAPES_ENABLE_BACKWARDCPP spdlog::error("try to deallocate invalid pointer ({}). this={}", (void*)ptr, (void*)this); backward::StackTrace st; diff --git a/redGrapesConfig.cmake b/redGrapesConfig.cmake index 76814429..cd61ebec 100644 --- a/redGrapesConfig.cmake +++ b/redGrapesConfig.cmake @@ -39,10 +39,6 @@ else() message(STATUS "Found hwloc") endif() -set(Backward_DIR "${CMAKE_CURRENT_LIST_DIR}/share/thirdParty/bombela/backward-cpp") -find_package(Backward) - - if( NOT TARGET redGrapes ) add_library(redGrapes ${CMAKE_CURRENT_LIST_DIR}/redGrapes/resource/resource.cpp @@ -76,7 +72,6 @@ target_link_libraries(redGrapes PUBLIC ${Boost_LIBRARIES}) target_link_libraries(redGrapes PUBLIC fmt::fmt) target_link_libraries(redGrapes PUBLIC spdlog::spdlog) target_link_libraries(redGrapes PUBLIC ${HWLOC}) -target_link_libraries(redGrapes PUBLIC Backward::Backward) set(redGrapes_INCLUDE_DIRS ${redGrapes_CONFIG_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR}) set(redGrapes_INCLUDE_DIRS ${redGrapes_INCLUDE_DIRS} "${CMAKE_CURRENT_LIST_DIR}/share/thirdParty/akrzemi/optional/include") @@ -85,8 +80,17 @@ set(redGrapes_INCLUDE_DIRS ${redGrapes_INCLUDE_DIRS} ${HWLOC_INCLUDE_DIR}) set(redGrapes_LIBRARIES ${Boost_LIBRARIES} fmt::fmt spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT} ${HWLOC}) +option(redGrapes_ENABLE_BACKWARDCPP "Enable extended debugging with `backward-cpp`" OFF) option(redGrapes_ENABLE_PERFETTO "Enable tracing support with perfetto" OFF) +if(redGrapes_ENABLE_BACKWARDCPP) + set(Backward_DIR "${CMAKE_CURRENT_LIST_DIR}/share/thirdParty/bombela/backward-cpp") + find_package(Backward) + + add_compile_definitions(REDGRAPES_ENABLE_BACKWARDCPP=1) + target_link_libraries(redGrapes PUBLIC Backward::Backward) +endif() + if(redGrapes_ENABLE_PERFETTO) add_compile_definitions(PERFETTO_ALLOW_SUB_CPP17) add_compile_definitions(REDGRAPES_ENABLE_TRACE=1)