Skip to content

Commit

Permalink
Detect backtrace (execinfo.h) with check_symbol_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarguinaud committed May 27, 2024
1 parent 6e6bb1f commit 72c46ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ ecbuild_add_option( FEATURE BUDDY_MALLOC
DEFAULT ON
)

check_symbol_exists(backtrace execinfo.h HAVE_BACKTRACE)

## fypp preprocessor flags
if(HAVE_BUDDY_MALLOC)
list( APPEND fypp_defines "-DUSE_BUDDY_MALLOC")
Expand Down Expand Up @@ -174,6 +176,10 @@ foreach(prec ${precisions})
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LIBNAME}_${prec}>
)

if( HAVE_BACKTRACE )
target_compile_definitions( ${LIBNAME}_${prec} PRIVATE HAVE_BACKTRACE )
endif()

if( prec MATCHES sp )
target_compile_definitions( ${LIBNAME}_${prec} PRIVATE PARKIND1_SINGLE )
endif()
Expand Down
3 changes: 2 additions & 1 deletion field_backtrace.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <string.h>

#ifdef HAVE_BACKTRACE

#include <execinfo.h>
#include <stdio.h>
Expand All @@ -26,7 +27,7 @@ void field_backtrace_ (char * str, int * p1, int * p2, int * plen)
}


#ifdef UNDEF
#else

void field_backtrace_ (char * str, int * p1, int * p2, int * plen)
{
Expand Down

0 comments on commit 72c46ad

Please sign in to comment.