Skip to content
Snippets Groups Projects
Commit bca16e8f authored by Markus Blatt's avatar Markus Blatt
Browse files

Merged recent changes from the trunk and add test for cxa_demangle to CMake build system.

[[Imported from SVN: r7129]]
parent 1c48a836
No related branches found
No related tags found
No related merge requests found
set(modules DuneBoost.cmake
DuneCommonMacros.cmake
DuneCxaDemangle.cmake
DuneDoc.cmake
DuneDoxygen.cmake
DuneMacros.cmake
......
# Module that checks whether the compiler supports the
# abi::__cxa_demangle function required to
# make the type names returned by typeid() human-readable
#
# Sets the following variable:
# HAVE_CXA_DEMANGLE
#
# perform tests
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <cxxabi.h>
int main(void){
int foobar = 0;
const char *foo = typeid(foobar).name();
int status;
char *demangled = abi::__cxa_demangle( foo, 0, 0, &status );
}" HAVE_CXA_DEMANGLE)
......@@ -409,6 +409,8 @@ macro(dune_project)
# set required compiler flags for C++11 (former C++0x)
find_package(CXX11Features)
include(DuneCxaDemangle)
# search for headers
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
......
MODULES = DuneBoost.cmake \
DuneCommonMacros.cmake \
DuneCxaDemangle.cmake \
DuneDoc.cmake \
DuneDoxygen.cmake \
DuneMacros.cmake \
......
......@@ -53,6 +53,9 @@
/* Define to 1 if you have the <boost/shared_ptr.hpp> header file. */
#cmakedefine HAVE_BOOST_SHARED_PTR_HPP 1
/* does the compiler support abi::__cxa_demangle */
#cmakedefine HAVE_CXA_DEMANGLE 1
/* Define if you have LAPACK library. */
#cmakedefine HAVE_LAPACK 1
......
......@@ -12,9 +12,9 @@
#include <string>
#include <typeinfo>
#if defined(__GNUC__) && ! defined(__clang__)
#if HAVE_CXA_DEMANGLE
#include <cxxabi.h>
#endif // #ifdef __GNUC__
#endif // #if HAVE_CXA_DEMANGLE
namespace Dune {
......@@ -23,7 +23,7 @@ namespace Dune {
std::string className ( T &t )
{
std::string className = typeid( t ).name();
#if defined(__GNUC__) && ! defined(__clang__)
#if HAVE_CXA_DEMANGLE
int status;
char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status );
if( demangled )
......@@ -31,7 +31,7 @@ namespace Dune {
className = demangled;
std::free( demangled );
}
#endif // #ifdef __GNUC__
#endif // #if HAVE_CXA_DEMANGLE
return className;
}
......@@ -40,7 +40,7 @@ namespace Dune {
std::string className ()
{
std::string className = typeid( T ).name();
#if defined(__GNUC__) && ! defined(__clang__)
#if HAVE_CXA_DEMANGLE
int status;
char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status );
if( demangled )
......@@ -48,7 +48,7 @@ namespace Dune {
className = demangled;
std::free( demangled );
}
#endif // #ifdef __GNUC__
#endif // #if HAVE_CXA_DEMANGLE
return className;
}
......
......@@ -27,6 +27,7 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([DUNE_LINKCXX])
AC_REQUIRE([DUNE_CHECKDEPRECATED])
AC_REQUIRE([DUNE_CHECKUNUSED])
AC_REQUIRE([DUNE_CHECK_CXA_DEMANGLE])
AC_REQUIRE([DUNE_SET_MINIMAL_DEBUG_LEVEL])
AC_REQUIRE([DUNE_PATH_XDR])
AC_REQUIRE([DUNE_MPI])
......
# Check if the compiler supports the abi::__cxa_demangle function required to
# make the type names returned by typeid() human-readable
AC_DEFUN([DUNE_CHECK_CXA_DEMANGLE],[
AC_CACHE_CHECK([for abi::__cxa_demangle], dune_cv_cxa_demangle, [
AC_LANG_PUSH([C++])
AC_TRY_COMPILE([
#include <cxxabi.h>
],
[
int foobar = 0;
const char *foo = typeid(foobar).name();
int status;
char *demangled = abi::__cxa_demangle( foo, 0, 0, &status );
],
dune_cv_cxa_demangle="yes",
dune_cv_cxa_demangle="no")
AC_LANG_POP([C++])
])
AS_IF([test "x$dune_cv_cxa_demangle" = "xyes"],
[AC_DEFINE_UNQUOTED(HAVE_CXA_DEMANGLE,
1,
[does the compiler support abi::__cxa_demangle])])
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment