2017-07-17 14:21:43 +00:00
|
|
|
include (CMakePushCheckState)
|
|
|
|
cmake_push_check_state ()
|
|
|
|
|
2017-09-21 20:55:20 +00:00
|
|
|
option (ENABLE_UNWIND "Enable libunwind (better stacktraces)" ON)
|
|
|
|
|
|
|
|
if (ENABLE_UNWIND)
|
|
|
|
|
2017-09-01 17:21:03 +00:00
|
|
|
if (CMAKE_SYSTEM MATCHES "Linux" AND NOT ARCH_ARM AND NOT ARCH_32)
|
2017-06-23 14:41:07 +00:00
|
|
|
option (USE_INTERNAL_UNWIND_LIBRARY "Set to FALSE to use system unwind library instead of bundled" ${NOT_UNBUNDLED})
|
|
|
|
else ()
|
|
|
|
option (USE_INTERNAL_UNWIND_LIBRARY "Set to FALSE to use system unwind library instead of bundled" OFF)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (NOT USE_INTERNAL_UNWIND_LIBRARY)
|
|
|
|
find_library (UNWIND_LIBRARY unwind)
|
|
|
|
find_path (UNWIND_INCLUDE_DIR NAMES unwind.h PATHS ${UNWIND_INCLUDE_PATHS})
|
|
|
|
|
|
|
|
include (CheckCXXSourceCompiles)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${UNWIND_INCLUDE_DIR})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${UNWIND_LIBRARY})
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <ucontext.h>
|
2017-07-10 10:30:06 +00:00
|
|
|
#define UNW_LOCAL_ONLY
|
2017-06-23 14:41:07 +00:00
|
|
|
#include <libunwind.h>
|
|
|
|
int main () {
|
|
|
|
ucontext_t context;
|
|
|
|
unw_cursor_t cursor;
|
|
|
|
unw_init_local_signal(&cursor, &context);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_UNWIND_INIT_LOCAL_SIGNAL)
|
|
|
|
if (NOT HAVE_UNWIND_INIT_LOCAL_SIGNAL)
|
|
|
|
set(UNWIND_LIBRARY "")
|
|
|
|
set(UNWIND_INCLUDE_DIR "")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (UNWIND_LIBRARY AND UNWIND_INCLUDE_DIR)
|
|
|
|
set (USE_UNWIND 1)
|
2017-09-01 17:21:03 +00:00
|
|
|
elseif (CMAKE_SYSTEM MATCHES "Linux" AND NOT ARCH_ARM AND NOT ARCH_32)
|
2017-06-23 14:41:07 +00:00
|
|
|
set (USE_INTERNAL_UNWIND_LIBRARY 1)
|
|
|
|
set (UNWIND_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libunwind/include")
|
|
|
|
set (UNWIND_LIBRARY unwind)
|
|
|
|
set (USE_UNWIND 1)
|
|
|
|
endif ()
|
|
|
|
|
2017-09-21 20:55:20 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-06-23 14:41:07 +00:00
|
|
|
message (STATUS "Using unwind=${USE_UNWIND}: ${UNWIND_INCLUDE_DIR} : ${UNWIND_LIBRARY}")
|
2017-07-17 14:21:43 +00:00
|
|
|
|
|
|
|
cmake_pop_check_state ()
|