-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add libbacktrace package #174
Changes from all commits
45a37ae
e54642d
01e6dae
d65f7e0
18bb8a1
604ca6d
9e56bc7
490d8b8
9b1b658
8d9b00a
59d8f0b
dfe10e8
329c76a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying | ||
# file Copyright.txt or https://cmake.org/licensing for details. | ||
|
||
#.rst: | ||
# Findlibbacktrace | ||
# ------- | ||
# | ||
# Finds the libbacktrace library | ||
# | ||
# This will define the following variables:: | ||
# | ||
# libbacktrace_FOUND - True if the system has the libbacktrace library | ||
# libbacktrace_VERSION - The version of the libbacktrace library which was found | ||
# | ||
# and the following imported targets:: | ||
# | ||
# libbacktrace::libbacktrace - The libbacktrace library | ||
|
||
find_path(libbacktrace_INCLUDE_DIR | ||
NAMES backtrace.h | ||
PATHS "${libbacktrace_ROOT}/include" | ||
) | ||
|
||
if(WIN32) | ||
set(_libbacktrace_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
set(_libbacktrace_ORIG_CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES .so .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
set(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES}) | ||
endif() | ||
|
||
find_library(libbacktrace_LIBRARY | ||
NAMES backtrace | ||
PATHS "${libbacktrace_ROOT}/lib" | ||
) | ||
|
||
if(WIN32) | ||
# Restore the original find library ordering | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_libbacktrace_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
set(CMAKE_FIND_LIBRARY_PREFIXES ${_libbacktrace_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}) | ||
endif() | ||
|
||
set(libbacktrace_VERSION ${PC_libbacktrace_VERSION}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(libbacktrace | ||
FOUND_VAR libbacktrace_FOUND | ||
REQUIRED_VARS | ||
libbacktrace_LIBRARY | ||
libbacktrace_INCLUDE_DIR | ||
VERSION_VAR libbacktrace_VERSION | ||
) | ||
|
||
if(libbacktrace_FOUND) | ||
set(libbacktrace_LIBRARIES ${libbacktrace_LIBRARY}) | ||
set(libbacktrace_INCLUDE_DIRS ${libbacktrace_INCLUDE_DIR}) | ||
set(libbacktrace_DEFINITIONS ${PC_libbacktrace_CFLAGS_OTHER}) | ||
endif() | ||
|
||
if(libbacktrace_FOUND AND NOT TARGET libbacktrace::libbacktrace) | ||
add_library(libbacktrace::libbacktrace UNKNOWN IMPORTED) | ||
set_target_properties(libbacktrace::libbacktrace PROPERTIES | ||
IMPORTED_LOCATION "${libbacktrace_LIBRARY}" | ||
INTERFACE_COMPILE_OPTIONS "${PC_libbacktrace_CFLAGS_OTHER}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${libbacktrace_INCLUDE_DIR}" | ||
) | ||
endif() | ||
|
||
mark_as_advanced( | ||
libbacktrace_INCLUDE_DIR | ||
libbacktrace_LIBRARY | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# !!! DO NOT PLACE HEADER GUARDS HERE !!! | ||
|
||
include(hunter_add_version) | ||
include(hunter_cacheable) | ||
include(hunter_configuration_types) | ||
include(hunter_download) | ||
include(hunter_pick_scheme) | ||
|
||
hunter_add_version( | ||
PACKAGE_NAME | ||
libbacktrace | ||
VERSION | ||
1.0.0-ca0de051 | ||
URL | ||
"https://github.com/ianlancetaylor/libbacktrace/archive/ca0de0517f3be44fedf5a2c01cfaf6437d4cae68.tar.gz" | ||
SHA1 | ||
7c7db4d096d96f329c453fb97b7a456fe823e943 | ||
) | ||
|
||
hunter_configuration_types(libbacktrace CONFIGURATION_TYPES Release) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why hard code the configutation types. If debug is not supportet please add a comment about the reasons There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it uses the autotools scheme and this can only build one build type. If you remove this it will show an error:
|
||
hunter_pick_scheme(DEFAULT url_sha1_autotools) | ||
hunter_cacheable(libbacktrace) | ||
hunter_download( | ||
PACKAGE_NAME libbacktrace | ||
PACKAGE_INTERNAL_DEPS_ID "1" | ||
PACKAGE_UNRELOCATABLE_TEXT_FILES | ||
"lib/libbacktrace.la" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.. spelling:: | ||
|
||
libbacktrace | ||
|
||
.. index:: | ||
single: Logging ; libbacktrace | ||
|
||
.. _pkg.libbacktrace: | ||
|
||
libbacktrace | ||
============ | ||
|
||
- `Official <https://github.com/ianlancetaylor/libbacktrace>`__ | ||
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/libbacktrace/CMakeLists.txt>`__ | ||
- Added by `Joerg-Christian Boehme <https://github.com/Bjoe>`__ (`pr-174 <https://github.com/cpp-pm/hunter/pull/174>`__) | ||
|
||
.. literalinclude:: /../examples/libbacktrace/CMakeLists.txt | ||
:language: cmake | ||
:start-after: # DOCUMENTATION_START { | ||
:end-before: # DOCUMENTATION_END } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) | ||
# All rights reserved. | ||
|
||
cmake_minimum_required(VERSION 3.2) | ||
|
||
# Emulate HunterGate: | ||
# * https://github.com/cpp-pm/gate | ||
include("../common.cmake") | ||
|
||
project(download-libbacktrace) | ||
|
||
# DOCUMENTATION_START { | ||
hunter_add_package(libbacktrace) | ||
find_package(libbacktrace REQUIRED) | ||
|
||
add_executable(boo boo.cpp) | ||
target_link_libraries(boo PUBLIC libbacktrace::libbacktrace) | ||
# DOCUMENTATION_END } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <backtrace.h> | ||
|
||
int main() { | ||
backtrace_state* state = nullptr; | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the variable reset again. Could you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be "reset" because other
find_library()
in other modules etc. shouldn't be affected ! See also FindBoost and other find modules. They all do it that way ... I added a comment.