--- src/core/CMakeLists.txt.orig	2016-05-01 10:50:12 UTC
+++ src/core/CMakeLists.txt
@@ -51,12 +51,14 @@ wee-version.c wee-version.h)
 include(CheckSymbolExists)
 check_symbol_exists(flock "sys/file.h" HAVE_FLOCK)
 
-if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
-  find_library(EXECINFO_LIB_PATH execinfo /usr/local/lib)
-  set(CMAKE_REQUIRED_LIBRARIES "${EXECINFO_LIB_PATH}")
-  check_function_exists(backtrace HAVE_BACKTRACE)
-else()
-  check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
+if(ENABLE_BACKTRACE)
+  if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+    find_library(EXECINFO_LIB_PATH execinfo /usr/local/lib)
+    set(CMAKE_REQUIRED_LIBRARIES "${EXECINFO_LIB_PATH}")
+    check_function_exists(backtrace HAVE_BACKTRACE)
+  else()
+    check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
+  endif()
 endif()
 
 if(GNUTLS_FOUND)
