autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check whether AC_PROG_X has failed


From: Nick Bowler
Subject: Re: Check whether AC_PROG_X has failed
Date: Fri, 28 Nov 2014 10:34:50 -0500
User-agent: Mutt/1.5.22 (2013-10-16)

Hello,

On 2014-11-28 11:51 +0100, Shahbaz Youssefi wrote:
> The problem is that if you call AC_PROG_CXX, even if there are no C++
> compilers, *CXX is set to g++ anyway* and the macro doesn't provide a means
> to understand if it actually succeeded or not. This is a problem because if
> you want to enable a feature only if a C++ compiler exists, you need to be
> able to well, check if there is a C++ compiler. This is the relevant Stack
> Overflow question: http://stackoverflow.com/q/27111000/912144
> 
> Now I'm by no means an expert with m4, but I think I could hack away at
> this. Before sending a patch however, I wanted to make sure if the idea is
> acceptable.

To contrast: AC_PROG_CC behaviour is to fail hard if no C compiler is
found (or if certain tests of it fail).

You may find that defining what "succeeded" means for AC_PROG_CXX
will be hard to do.  But you can always do something like this in
configure.ac (totally untested):

  AC_PROG_CXX
  
  AC_LANG([C++])
  AC_CACHE_CHECK([whether the C++ compiler works], [my_cv_cxx_works],
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <iostream>],
                         [std::cout << "Hello, World" << std::endl;])],
      [my_cv_cxx_works=yes], [my_cv_cxx_works=no])])

  AS_IF([test x"$my_cv_cxx_works" != x"yes"],
    [AC_MSG_ERROR([sorry, can't help you])])

Perhaps AC_PROG_CXX would be improved by simply performing a test like
the above at the end.

Regards,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]