Skip to content

Commit

Permalink
cmake: make BackwardCpp dependency optional (for debug only)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsippel committed Nov 8, 2023
1 parent aa9c906 commit 7a7ce88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions redGrapes/memory/chunked_bump_alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <redGrapes/dispatch/thread/cpuset.hpp>
#include <redGrapes/util/trace.hpp>

#ifndef NDEBUG
#if REDGRAPES_ENABLE_BACKWARDCPP
#include <backward.hpp>
#endif

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions redGrapesConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit 7a7ce88

Please sign in to comment.