From 1802b7c6fe219f2774724a8c32f803bbd3e4d567 Mon Sep 17 00:00:00 2001 From: Danilo Spinella Date: Fri, 31 May 2019 10:57:38 +0200 Subject: [PATCH] Check for execinfo.h and add libexecinfo if needed Some systems (e.g. musl) do not have execinfo.h header. Check if libexecinfo (library that provides execinfo.h header and its functions) is installed in the system, and add its linker flag if needed. --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3332be8c8..ab8f60c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -323,6 +323,19 @@ else() set( ZLIB_LIBRARY z ) endif() +if( HAVE_VM_JIT AND UNIX ) + check_symbol_exists( "backtrace" "execinfo.h" HAVE_BACKTRACE ) + if( NOT HAVE_BACKTRACE ) + set( CMAKE_REQUIRED_FLAGS "-lexecinfo" ) + check_symbol_exists( "backtrace" "execinfo.h" HAVE_LIBEXECINFO ) + if( HAVE_LIBEXECINFO ) + set( ALL_C_FLAGS "${ALL_C_FLAGS} -lexecinfo" ) + else( HAVE_LIBEXECINFO ) + set( HAVE_VM_JIT NO ) + endif( HAVE_LIBEXECINFO ) + endif( NOT HAVE_BACKTRACE ) +endif( HAVE_VM_JIT AND UNIX ) + if( ${HAVE_VM_JIT} ) if( ASMJIT_FOUND AND NOT FORCE_INTERNAL_ASMJIT ) message( STATUS "Using system asmjit, includes found at ${ASMJIT_INCLUDE_DIR}" )