From: bangerth Date: Wed, 14 Jan 2009 14:24:50 +0000 (+0000) Subject: Check for all those new C++0x header files. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1ad1e46cf992a78efe6bd8bcabf06e05f4a56f2;p=dealii-svn.git Check for all those new C++0x header files. git-svn-id: https://svn.dealii.org/trunk@18217 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 1bbf090ed0..e4aefbe9bc 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -489,25 +489,25 @@ AC_DEFUN(DEAL_II_SET_CXX_FLAGS, dnl dnl BOOST uses long long, so don't warn about this CXXFLAGSG="$CXXFLAGSG -Wno-long-long" - dnl See whether the gcc we use already supports C++0x features. - dnl + dnl See whether the gcc we use already has a flag for C++0x features. OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS=-std=c++0x - AC_MSG_CHECKING(whether compiler supports C++0x) + AC_MSG_CHECKING(whether compiler has a flag to support C++0x) AC_TRY_COMPILE([], [;], [ AC_MSG_RESULT(yes) - CXXFLAGSG="$CXXFLAGSG -std=c++0x" - CXXFLAGSO="$CXXFLAGSO -std=c++0x" - AC_DEFINE(DEAL_II_CAN_USE_CXX0X, 1, - [Defined if the compiler we use supports the upcoming C++0x standard.]) + test_cxx0x=yes ], [ AC_MSG_RESULT(no) + test_cxx0x=no ]) CXXFLAGS="${OLD_CXXFLAGS}" + if test "x$test_cxx0x" = "xyes" ; then + DEAL_II_CHECK_CXX0X_COMPONENTS("-std=c++0x") + fi dnl On some gcc 4.3 snapshots, a 'const' qualifier on a return type triggers a dnl warning. This is unfortunate, since we happen to stumble on this @@ -1096,6 +1096,98 @@ AC_DEFUN(DEAL_II_SET_CXX_DEBUG_FLAG, dnl +dnl ------------------------------------------------------------- +dnl Given the command line flag specified as argument to this macro, +dnl test whether all components that we need from the C++0X +dnl standard are actually available. If so, add the flag to +dnl CXXFLAGS.g and CXXFLAGS.o, and set a flag in config.h +dnl +dnl Usage: DEAL_II_CHECK_CXX0X_COMPONENTS(cxxflag) +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_CXX0X_COMPONENTS, dnl +[ + OLD_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$1" + + all_cxx0x_available=yes + + AC_MSG_CHECKING(for std::array) + AC_TRY_COMPILE( + [#include ], + [ std::array p; p[0];], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::condition_variable) + AC_TRY_COMPILE( + [#include ], + [ std::condition_variable c; c.notify_all()], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::function and std::bind) + AC_TRY_COMPILE( + [#include + void f(int, double); ], + [ std::function + g = std::bind (f, std::placeholders::_1, 1.1) ;], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::shared_ptr) + AC_TRY_COMPILE( + [#include ], + [ std::shared_ptr p(new int(3))], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::thread) + AC_TRY_COMPILE( + [#include + void f(int); ], + [ std::thread t(f,1); t.join();], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::mutex) + AC_TRY_COMPILE( + [#include ], + [ std::mutex m; m.lock();], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + AC_MSG_CHECKING(for std::tuple) + AC_TRY_COMPILE( + [#include ], + [ std::tuple p(1,1.1,'a')], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); all_cxx0x_available=no ] + ) + + CXXFLAGS="${OLD_CXXFLAGS}" + + AC_MSG_CHECKING(whether C++0x support is complete enough) + if test "x$all_cxx0x_available" = "xyes" ; then + AC_MSG_RESULT(yes) + + CXXFLAGSG="$CXXFLAGSG $1" + CXXFLAGSO="$CXXFLAGSO $1" + + AC_DEFINE(DEAL_II_CAN_USE_CXX0X, 1, + [Defined if the compiler we use supports the upcoming C++0x standard.]) + else + AC_MSG_RESULT(no) + fi +]) + + dnl ------------------------------------------------------------- dnl Determine the C compiler in use. Return the name and possibly dnl version of this compiler in CC_VERSION. This function is almost diff --git a/deal.II/configure b/deal.II/configure index ad5ecb513e..a4d4e6f06c 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 18101 . +# From configure.in Revision: 18210 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for deal.II 6.2.pre. # @@ -3896,11 +3896,11 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ CXXFLAGSG="$CXXFLAGSG -Wno-long-long" - OLD_CXXFLAGS="$CXXFLAGS" + OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS=-std=c++0x - { echo "$as_me:$LINENO: checking whether compiler supports C++0x" >&5 -echo $ECHO_N "checking whether compiler supports C++0x... $ECHO_C" >&6; } + { echo "$as_me:$LINENO: checking whether compiler has a flag to support C++0x" >&5 +echo $ECHO_N "checking whether compiler has a flag to support C++0x... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3936,13 +3936,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } - CXXFLAGSG="$CXXFLAGSG -std=c++0x" - CXXFLAGSO="$CXXFLAGSO -std=c++0x" - -cat >>confdefs.h <<\_ACEOF -#define DEAL_II_CAN_USE_CXX0X 1 -_ACEOF - + test_cxx0x=yes else echo "$as_me: failed program was:" >&5 @@ -3951,12 +3945,374 @@ sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } + test_cxx0x=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="${OLD_CXXFLAGS}" + if test "x$test_cxx0x" = "xyes" ; then + + OLD_CXXFLAGS="$CXXFLAGS" + CXXFLAGS=""-std=c++0x"" + + all_cxx0x_available=yes + + { echo "$as_me:$LINENO: checking for std::array" >&5 +echo $ECHO_N "checking for std::array... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + std::array p; p[0]; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::condition_variable" >&5 +echo $ECHO_N "checking for std::condition_variable... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + std::condition_variable c; c.notify_all() + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::function and std::bind" >&5 +echo $ECHO_N "checking for std::function and std::bind... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + void f(int, double); +int +main () +{ + std::function + g = std::bind (f, std::placeholders::_1, 1.1) ; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::shared_ptr" >&5 +echo $ECHO_N "checking for std::shared_ptr... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + std::shared_ptr p(new int(3)) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::thread" >&5 +echo $ECHO_N "checking for std::thread... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + void f(int); +int +main () +{ + std::thread t(f,1); t.join(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::mutex" >&5 +echo $ECHO_N "checking for std::mutex... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + std::mutex m; m.lock(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for std::tuple" >&5 +echo $ECHO_N "checking for std::tuple... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + std::tuple p(1,1.1,'a') + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; }; all_cxx0x_available=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + CXXFLAGS="${OLD_CXXFLAGS}" + + { echo "$as_me:$LINENO: checking whether C++0x support is complete enough" >&5 +echo $ECHO_N "checking whether C++0x support is complete enough... $ECHO_C" >&6; } + if test "x$all_cxx0x_available" = "xyes" ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + + CXXFLAGSG="$CXXFLAGSG "-std=c++0x"" + CXXFLAGSO="$CXXFLAGSO "-std=c++0x"" + + +cat >>confdefs.h <<\_ACEOF +#define DEAL_II_CAN_USE_CXX0X 1 +_ACEOF + + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + fi + + fi CXXFLAGS="-Wreturn-type -Werror" { echo "$as_me:$LINENO: checking whether qualifiers in return types lead to a warning" >&5