Skip to content

Commit

Permalink
mk,cmake: add backtrace support and fix linking on OpenBSD (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Mar 2, 2022
1 parent 3d8eefd commit 89130b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ endif()
# Module/Package Includes
#
include(CheckIncludeFile)
find_package(Backtrace)
find_package(Threads)
find_package(OpenSSL)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
)

Expand Down
3 changes: 3 additions & 0 deletions mk/re.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89130b9

Please sign in to comment.