Skip to content

Commit

Permalink
cmake: Add libunwind detection
Browse files Browse the repository at this point in the history
Signed-off-by: Hofi <[email protected]>
  • Loading branch information
HofiOne committed Feb 25, 2025
1 parent b97b959 commit b2cedd2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ endif()

set(SYSLOG_NG_ENABLE_LINUX_CAPS ${PC_LIBCAP_FOUND})

find_package (LIBUNWIND)
if (ENABLE_LIBUNWIND)
if (NOT LIBUNWIND_FOUND)
message (FATAL_ERROR "ENABLE_LIBUNWIND is defined, but the libunwind library could not be found.")
endif ()
endif ()
if (LIBUNWIND_FOUND)
set (CMAKE_REQUIRED_INCLUDES ${LIBUNWIND_INCLUDE_DIR})
set (CMAKE_REQUIRED_LIBRARIES ${LIBUNWIND_LIBRARY})
endif ()
option (ENABLE_LIBUNWIND "Enable stackdump using libunwind" ${LIBUNWIND_FOUND})
set (SYSLOG_NG_ENABLE_STACKDUMP ${ENABLE_LIBUNWIND})

if (WITH_GETTEXT)
set(CMAKE_PREFIX_PATH ${WITH_GETTEXT})
find_package(Gettext REQUIRED QUIET)
Expand Down
27 changes: 27 additions & 0 deletions cmake/Modules/FindLIBUNWIND.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ############################################################################
# Copyright (c) 2025 One Identity LLC.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# As an additional exemption you are allowed to compile & link against the
# OpenSSL libraries as published by the OpenSSL project. See the file
# COPYING for details.
#
# ############################################################################

include (LibFindMacros)

libfind_pkg_detect (LIBUNWIND libunwind FIND_PATH libunwind.h FIND_LIBRARY unwind)
libfind_process (LIBUNWIND)

0 comments on commit b2cedd2

Please sign in to comment.