From 0fe6703d026f2f1d714c06140c8dcad331c91e78 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Wed, 2 Mar 2022 08:48:54 +0100 Subject: [PATCH] mk,cmake: add backtrace support and fix linking on OpenBSD --- CMakeLists.txt | 16 +++++++++++++--- mk/re.mk | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3deb09928..851038fd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ endif() # Module/Package Includes # include(CheckIncludeFile) +find_package(Backtrace) find_package(Threads) find_package(OpenSSL) @@ -68,6 +69,10 @@ if(HAVE_UNISTD_H) add_definitions(-DHAVE_UNISTD_H) endif() +if(Backtrace_FOUND) + add_definitions(-DHAVE_EXECINFO) +endif() + if(CMAKE_USE_PTHREADS_INIT) add_definitions(-DHAVE_PTHREAD) set(HAVE_PTHREAD ON) @@ -457,10 +462,15 @@ if(WIN32) iphlpapi wsock32 ws2_32 + ${CMAKE_THREAD_LIBS_INIT} ) else() - target_link_libraries(re-shared - PRIVATE -L/opt/local/lib ${OPENSSL_LIBRARIES} -lpthread) + target_link_libraries(re-shared PRIVATE + -L/opt/local/lib + ${OPENSSL_LIBRARIES} + ${Backtrace_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ) endif() set_target_properties(re-shared PROPERTIES PUBLIC_HEADER include/re.h) @@ -482,7 +492,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ) endif() target_link_libraries(re-static - PUBLIC ${OPENSSL_LIBRARIES} -lpthread + PUBLIC ${OPENSSL_LIBRARIES} ${Backtrace_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} PRIVATE -L/opt/local/lib ) diff --git a/mk/re.mk b/mk/re.mk index d1dfc82a7..9b5f92687 100644 --- a/mk/re.mk +++ b/mk/re.mk @@ -580,6 +580,9 @@ endif HAVE_EXECINFO := $(shell $(call CC_TEST,execinfo.h)) ifneq ($(HAVE_EXECINFO),) CFLAGS += -DHAVE_EXECINFO +ifeq ($(OS),openbsd) +LFLAGS += -lexecinfo +endif endif CFLAGS += -DHAVE_FORK