From fb1d5dd77271699b77bfdc42c0ceef7541582169 Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Sat, 6 Mar 2021 01:18:16 +0100 Subject: [PATCH] remove cxa demangle cmake check, replaced by simple __has_include preprocessor check --- cmake/modules/CMakeLists.txt | 1 - cmake/modules/DuneCxaDemangle.cmake | 18 ------------------ cmake/modules/DuneMacros.cmake | 1 - config.h.cmake | 3 --- dune/common/classname.hh | 3 ++- dune/common/test/CMakeLists.txt | 3 +-- dune/common/test/classnametest.cc | 2 +- 7 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 cmake/modules/DuneCxaDemangle.cmake diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 7da06e040..b857dc4dc 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -17,7 +17,6 @@ install(FILES DuneAddPybind11Module.cmake DuneCMakeCompat.cmake DuneCommonMacros.cmake - DuneCxaDemangle.cmake DuneDoc.cmake DuneDoxygen.cmake DuneEnableAllPackages.cmake diff --git a/cmake/modules/DuneCxaDemangle.cmake b/cmake/modules/DuneCxaDemangle.cmake deleted file mode 100644 index 08d557c17..000000000 --- a/cmake/modules/DuneCxaDemangle.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# This module checks whether the compiler supports the -# abi::__cxa_demangle function required to -# make the type names returned by typeid() human-readable -# -# It sets the variable :code:`HAVE_CXA_DEMANGLE` with the result. -# -include_guard(GLOBAL) - -include(CheckCXXSourceCompiles) - -CHECK_CXX_SOURCE_COMPILES("#include <typeinfo> -#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) diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index 162848014..bc4516a23 100644 --- a/cmake/modules/DuneMacros.cmake +++ b/cmake/modules/DuneMacros.cmake @@ -684,7 +684,6 @@ macro(dune_project) # check for C++ features, set compiler flags for C++14 or C++11 mode include(CheckCXXFeatures) - include(DuneCxaDemangle) # set include path and link path for the current project. include_directories("${CMAKE_BINARY_DIR}") diff --git a/config.h.cmake b/config.h.cmake index af0c478eb..dd10263a1 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -41,9 +41,6 @@ /* Define if you have a BLAS library. */ #cmakedefine HAVE_BLAS 1 -/* does the compiler support abi::__cxa_demangle */ -#cmakedefine HAVE_CXA_DEMANGLE 1 - /* Define if you have LAPACK library. */ #cmakedefine HAVE_LAPACK 1 diff --git a/dune/common/classname.hh b/dune/common/classname.hh index d1ec24b71..f24e330a6 100644 --- a/dune/common/classname.hh +++ b/dune/common/classname.hh @@ -14,7 +14,8 @@ #include <typeinfo> #include <type_traits> -#if HAVE_CXA_DEMANGLE +#if __has_include(<cxxabi.h>) && !DISABLE_CXA_DEMANGLE +#define HAVE_CXA_DEMANGLE 1 #include <cxxabi.h> #endif // #if HAVE_CXA_DEMANGLE diff --git a/dune/common/test/CMakeLists.txt b/dune/common/test/CMakeLists.txt index 08927abe5..f6e652f7b 100644 --- a/dune/common/test/CMakeLists.txt +++ b/dune/common/test/CMakeLists.txt @@ -71,13 +71,12 @@ dune_add_test(NAME check_fvector_size_fail2 dune_add_test(NAME classnametest-demangled SOURCES classnametest.cc LINK_LIBRARIES dunecommon - CMAKE_GUARD HAVE_CXA_DEMANGLE LABELS quick) dune_add_test(NAME classnametest-fallback SOURCES classnametest.cc LINK_LIBRARIES dunecommon - COMPILE_DEFINITIONS BASICCHECK + COMPILE_DEFINITIONS DISABLE_CXA_DEMANGLE LABELS quick) dune_add_test(SOURCES concept.cc diff --git a/dune/common/test/classnametest.cc b/dune/common/test/classnametest.cc index ee60e0c45..682d8d43d 100644 --- a/dune/common/test/classnametest.cc +++ b/dune/common/test/classnametest.cc @@ -131,7 +131,7 @@ int main() checkname(t, Dune::className(Base{}), {}, R"(\bBase\b)"); std::cout << std::endl; - #if BASICCHECK + #if !HAVE_CXA_DEMANGLE // in this case we only make sure that no segfault or similar happens return 0; #else -- GitLab