make cxxabi header optional

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-12-31 21:34:08 +02:00
parent 33b3d52c2d
commit 50331376b3
4 changed files with 21 additions and 7 deletions

View file

@ -326,13 +326,11 @@ set_package_properties(ExecInfo PROPERTIES
TYPE RECOMMENDED
)
# for symbols mangling while backtracing in core component
check_include_file_cxx(cxxabi.h HAVE_CXXABI)
# stored in qconfig.h.cmake
check_type_size(size_t QT_POINTER_SIZE)
# used in components, tests and JavaScriptCore
katie_check_header("cxxabi.h")
katie_check_function(getpwnam_r "pwd.h")
katie_check_function(getpwuid_r "pwd.h")
katie_check_function(getgrgid_r "grp.h")

View file

@ -5,6 +5,18 @@ set(KATIE_UIC "uic")
set(KATIE_RCC "rcc")
set(KATIE_MOC "bootstrap_moc")
# a function to check for header presence, if header is found a definition is
# added
function(KATIE_CHECK_HEADER FORHEADER)
string(REPLACE "." "_" underscoreheader "${FORHEADER}")
check_include_file_cxx("${FORHEADER}" HAVE_${underscoreheader})
if(HAVE_${underscoreheader})
string(TOUPPER "${underscoreheader}" upperheader)
add_definitions(-DQT_HAVE_${upperheader})
endif()
endfunction()
# a function to check for C function/definition, works for external functions
function(KATIE_CHECK_DEFINED FORDEFINITION FROMHEADER)
# see comment in top-level CMake file

View file

@ -442,7 +442,7 @@ if(WITH_INTL AND INTL_FOUND)
include_directories(${INTL_INCLUDES})
endif()
if(WITH_EXECINFO AND EXECINFO_FOUND AND HAVE_CXXABI)
if(WITH_EXECINFO AND EXECINFO_FOUND)
set(EXTRA_CORE_LIBS
${EXTRA_CORE_LIBS}
${EXECINFO_LIBRARIES}

View file

@ -51,7 +51,9 @@
#ifndef QT_NO_EXECINFO
# include "qcoreapplication.h"
# include <execinfo.h>
# include <cxxabi.h>
# ifdef QT_HAVE_CXXABI_H
# include <cxxabi.h>
# endif
#endif
QT_BEGIN_NAMESPACE
@ -1066,14 +1068,16 @@ static void qt_print_backtrace()
}
for (int i = 0; i < nptrs; i++) {
#ifdef QT_HAVE_CXXABI_H
int status;
char* demangled = abi::__cxa_demangle(strings[i], nullptr, nullptr, &status);
if (status == 0) {
::printf(" %s\n", demangled);
::free(demangled);
} else {
::printf(" %s\n", strings[i]);
continue;
}
#endif
::printf(" %s\n", strings[i]);
}
::free(strings);