Added libunwind to build process

But it's not used anywhere yet
master
Vladimir Stackov 2014-12-31 06:49:06 +03:00
parent c548d81fa8
commit afbad440b8
9 changed files with 164 additions and 0 deletions

View File

@ -41,6 +41,14 @@ else ( LIBLZO_FOUND )
set( LIBLZO_LIBRARIES )
endif( LIBLZO_FOUND )
find_package( LibUnwind COMPONENTS LIBUNWIND_HAS_UNW_GETCONTEXT LIBUNWIND_HAS_INIT_LOCAL )
if ( LIBUNWIND_FOUND )
ADD_DEFINITIONS( -DHAVE_LIBUNWIND )
include_directories( ${LIBUNWIND_INCLUDE_DIRS} )
else ( LIBUNWIND_FOUND )
set( LIBUNWIND_LIBRARIES )
endif( LIBUNWIND_FOUND )
file( GLOB sourceFiles "*.cc" )
add_executable( zbackup ${sourceFiles} ${protoSrcs} ${protoHdrs} )
@ -51,6 +59,7 @@ target_link_libraries( zbackup
${ZLIB_LIBRARIES}
${LIBLZMA_LIBRARIES}
${LIBLZO_LIBRARIES}
${LIBUNWIND_LIBRARIES}
)
install( TARGETS zbackup DESTINATION bin )

77
cmake/FindLibUnwind.cmake Normal file
View File

@ -0,0 +1,77 @@
#.rst:
# FindLibUnwind
# -----------
#
# Find LibUnwind
#
# Find LibUnwind headers and library
#
# ::
#
# LIBUNWIND_FOUND - True if libunwind is found.
# LIBUNWIND_INCLUDE_DIRS - Directory where libunwind headers are located.
# LIBUNWIND_LIBRARIES - Unwind libraries to link against.
# LIBUNWIND_HAS_UNW_GETCONTEXT - True if unw_getcontext() is found (required).
# LIBUNWIND_HAS_UNW_INIT_LOCAL - True if unw_init_local() is found (required).
# LIBUNWIND_VERSION_STRING - version number as a string (ex: "5.0.3")
#=============================================================================
# Copyright 2014 ZBackup contributors
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(LIBUNWIND_INCLUDE_DIR libunwind.h )
if(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
MESSAGE(FATAL_ERROR "found libunwind.h but corresponding unwind.h is absent!")
SET(LIBUNWIND_INCLUDE_DIR "")
endif()
find_library(LIBUNWIND_LIBRARY unwind)
if(LIBUNWIND_INCLUDE_DIR AND EXISTS "${LIBUNWIND_INCLUDE_DIR}/libunwind-common.h")
file(STRINGS "${LIBUNWIND_INCLUDE_DIR}/libunwind-common.h" LIBUNWIND_HEADER_CONTENTS REGEX "#define UNW_VERSION_[A-Z]+\t[0-9]*")
string(REGEX REPLACE ".*#define UNW_VERSION_MAJOR\t([0-9]*).*" "\\1" LIBUNWIND_VERSION_MAJOR "${LIBUNWIND_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define UNW_VERSION_MINOR\t([0-9]*).*" "\\1" LIBUNWIND_VERSION_MINOR "${LIBUNWIND_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define UNW_VERSION_EXTRA\t([0-9]*).*" "\\1" LIBUNWIND_VERSION_EXTRA "${LIBUNWIND_HEADER_CONTENTS}")
if(LIBUNWIND_VERSION_EXTRA)
set(LIBUNWIND_VERSION_STRING "${LIBUNWIND_VERSION_MAJOR}.${LIBUNWIND_VERSION_MINOR}.${LIBUNWIND_VERSION_EXTRA}")
else(not LIBUNWIND_VERSION_EXTRA)
set(LIBUNWIND_VERSION_STRING "${LIBUNWIND_VERSION_MAJOR}.${LIBUNWIND_VERSION_MINOR}")
endif()
unset(LIBUNWIND_HEADER_CONTENTS)
endif()
if (LIBUNWIND_LIBRARY)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${LibUnwind_FIND_QUIETLY})
CHECK_SYMBOL_EXISTS(unw_getcontext "${LIBUNWIND_INCLUDE_DIR}/libunwind.h" LIBUNWIND_HAS_UNW_GETCONTEXT)
CHECK_SYMBOL_EXISTS(unw_init_local "${LIBUNWIND_INCLUDE_DIR}/libunwind.h" LIBUNWIND_HAS_UNW_INIT_LOCAL)
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUnwind REQUIRED_VARS LIBUNWIND_INCLUDE_DIR
LIBUNWIND_LIBRARY
LIBUNWIND_HAS_UNW_GETCONTEXT
LIBUNWIND_HAS_UNW_INIT_LOCAL
VERSION_VAR LIBUNWIND_VERSION_STRING
)
if (LIBUNWIND_FOUND)
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARY})
set(LIBUNWIND_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIR})
endif ()
mark_as_advanced( LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARY )

View File

@ -2,3 +2,10 @@
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
bool verboseMode = true;
#ifndef NDEBUG
#ifdef HAVE_LIBUNWIND
#include "debug.hh"
#endif
#endif

View File

@ -12,9 +12,19 @@
#define dPrintf( ... ) (fprintf( stderr, __VA_ARGS__ ))
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#define dPrintBacktrace( ... ) ()
#else
#define dPrintBacktrace( ... ) ()
#endif
#else
#define dPrintf( ... )
#define dPrintBacktrace( ... ) ()
#endif

View File

@ -12,6 +12,10 @@ LICENSE-GPLV3.
EXCEPTION: This distribution of ZBackup may be linked against OpenSSL
according to the terms of the section below entitled "OpenSSL Exception."
ADDITION: This distribution of ZBackup uses sources from CMake project
which is distributed under the OSI-approved BSD 3-clause License.
See LICENSE-CMAKE for details.
This program 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 General

57
licenses/LICENSE-CMAKE Normal file
View File

@ -0,0 +1,57 @@
CMake - Cross Platform Makefile Generator
Copyright 2000-2014 Kitware, Inc.
Copyright 2000-2011 Insight Software Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of Kitware, Inc., the Insight Software Consortium,
nor the names of their contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
The above copyright and license notice applies to distributions of
CMake in source and binary form. Some source files contain additional
notices of original copyright by their contributors; see each source
for details. Third-party software packages supplied with CMake under
compatible licenses provide their own copyright notices documented in
corresponding subdirectories.
------------------------------------------------------------------------------
CMake was initially developed by Kitware with the following sponsorship:
* National Library of Medicine at the National Institutes of Health
as part of the Insight Segmentation and Registration Toolkit (ITK).
* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
Visualization Initiative.
* National Alliance for Medical Image Computing (NAMIC) is funded by the
National Institutes of Health through the NIH Roadmap for Medical Research,
Grant U54 EB005149.
* Kitware, Inc.