Question

I have forked a project that use autotools, and added functionalities that require c++11, then at least gcc 4.7.

What shall I add in configure.ac to check if gcc version 4.7 at least is available ? and then to use the minimal version that fits this requirement, or the system default version if it is higher ?

Était-ce utile?

La solution 2

There are other compilers beside GCC that support C++11, why make a test for a specific version of GCC?

The Autoconf Archive has a macro to require C++11 support, from whatever compiler is being used.

Autres conseils

Remember that a GCC installation also includes an executable with the same name but with a version included in the name. So if you have GCC version 4.7 then besides having a g++ program you also have a g++-4.7.

When you know that, you can use something like this:

dnl # Check which GCC version is wanted
AC_ARG_WITH(gcc,
  [ --with-gcc=<version> Use GCC (gcc and g++) of the specified version],
  [if test "$withval" != yes; then
     AC_PROG_CXX([g++-$withval g++ c++])
     AC_PROG_CC([gcc-$withval gcc])
   elif test "$withval" = yes; then
     AC_PROG_CXX([g++ c++])
     AC_PROG_CC([gcc])
   fi])

Modify to your requirements.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top