Skip to content
Snippets Groups Projects
Commit d1c6f06d authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[cmake] Re-add cmake tests for standard library features

We recently switched to built-in feature test macros for these, but as I had to
learn, libc++ does not have those macros. So back to the pedestrian way of
doing things...
parent bb33bed1
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
include(CheckCXXSymbolExists)
# C++ standard versions that this test knows about
set(CXX_VERSIONS 17 14 11)
......@@ -464,8 +465,69 @@ check_cxx_source_compiles("
" DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR
)
# ******************************************************************************
#
# Checks for standard library features
#
# While there are __cpp_lib_* feature test macros for all of these, those are
# unfortunately unreliable, as libc++ does not have feature test macros yet.
#
# In order to keep the tests short, they use check_cxx_symbol_exists(). That
# function can only test for macros and linkable symbols, however, so we wrap
# tested types into a call to std::move(). That should be safe, as std::move()
# does not require a complete type.
#
# ******************************************************************************
# Check whether we have <experimental/type_traits> (for is_detected et. al.)
check_include_file_cxx(
experimental/type_traits
DUNE_HAVE_HEADER_EXPERIMENTAL_TYPE_TRAITS
)
check_cxx_symbol_exists(
"std::make_unique<int>"
memory
DUNE_HAVE_CXX_MAKE_UNIQUE
)
check_cxx_symbol_exists(
"std::move<std::bool_constant<true>>"
"utility;type_traits"
DUNE_HAVE_CXX_BOOL_CONSTANT
)
if (NOT DUNE_HAVE_CXX_BOOL_CONSTANT)
check_cxx_symbol_exists(
"std::move<std::experimental::bool_constant<true>>"
"utility;experimental/type_traits"
DUNE_HAVE_CXX_EXPERIMENTAL_BOOL_CONSTANT
)
endif()
check_cxx_symbol_exists(
"std::apply<std::negate<int>,std::tuple<int>>"
"functional;tuple"
DUNE_HAVE_CXX_APPLY
)
if (NOT DUNE_HAVE_CXX_APPLY)
check_cxx_symbol_exists(
"std::experimental::apply<std::negate<int>,std::tuple<int>>"
"functional;experimental/tuple"
DUNE_HAVE_CXX_EXPERIMENTAL_APPLY
)
endif()
check_cxx_symbol_exists(
"std::experimental::make_array<int,int>"
"experimental/array"
DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY
)
check_cxx_symbol_exists(
"std::move<std::experimental::detected_t<std::decay_t,int>>"
"utility;experimental/type_traits"
DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED
)
......@@ -35,6 +35,27 @@
/* does the standard library provide <experimental/type_traits> ? */
#cmakedefine DUNE_HAVE_HEADER_EXPERIMENTAL_TYPE_TRAITS 1
/* does the standard library provide make_unique() ? */
#cmakedefine DUNE_HAVE_CXX_MAKE_UNIQUE 1
/* does the standard library provide bool_constant ? */
#cmakedefine DUNE_HAVE_CXX_BOOL_CONSTANT 1
/* does the standard library provide experimental::bool_constant ? */
#cmakedefine DUNE_HAVE_CXX_EXPERIMENTAL_BOOL_CONSTANT 1
/* does the standard library provide apply() ? */
#cmakedefine DUNE_HAVE_CXX_APPLY 1
/* does the standard library provide experimental::apply() ? */
#cmakedefine DUNE_HAVE_CXX_EXPERIMENTAL_APPLY 1
/* does the standard library provide experimental::make_array() ? */
#cmakedefine DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY 1
/* does the standard library provide experimental::is_detected ? */
#cmakedefine DUNE_HAVE_CXX_EXPERIMENTAL_IS_DETECTED 1
/* Define if you have a BLAS library. */
#cmakedefine HAVE_BLAS 1
......
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