octave-maintainers
[Top][All Lists]
Advanced

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

Re: Extending configure.ac to check for C++ header only libraries


From: Markus Mützel
Subject: Re: Extending configure.ac to check for C++ header only libraries
Date: Fri, 22 May 2020 10:25:09 +0200

Am 22. Mai 2020 um 09:40 Uhr schrieb "Kai Torben Ohlhus":
> On 5/21/20 10:51 AM, Abdallah Elshamy wrote:
> > Greetings,
> > 
> > I was trying to add RapidJSON [1] to Octave. At first, I thought about
> > using AC_CHECK_LIB (after some reading in configure.ac
> > I noticed that Octave uses the custom macro
> > OCTAVE_CHECK_LIB which I think is the same thing with some extra
> > parameters.) But, since RapidJSON [1] is a header-only library, I
> > thought about using AC_CHECK_HEADER. Which option is more preferable? 
> > 
> > Also, should I stop the configure script (with AC_MSG_ERROR for example)
> > If the library is not found or should I disable the functions ? (I think
> > the latter is better. If it is, any source on how to do this will be
> > helpful.)
> > 
> > Thanks in advance,
> > Abdallah
> > 
> 
> Dear Abdallah,
> Dear maintainers,  (please read below)
> 
> Good question.  RapidJSON should be an optional dependency, thus a
> warning shall be issued, if not available.  Later in your implementation
> you wrap your code with
> 
>    #if defined (HAVE_RAPIDJSON)
> 
>      // RapidJSON dependent code
> 
>    #else
> 
>      err_disabled_feature ("RapidJSON", "JSON library");
> 
>    #endif
> 
> to avoid unexpected usage.
> 
> For the rest, I think OCTAVE_CHECK_LIB is the right way
> to go.  This macro is documented here [2] and does everything needed,
> but a little too much :(
> 
> I tested a small code (AC_LANG_PUSH thanks to StackOverflow [3]):
> 
> 
>   ### Check for RAPIDJSON (C++ header only) library.
> 
>   AC_LANG_PUSH([C++])
>   OCTAVE_CHECK_LIB(rapidjson, RAPIDJSON,
>     [RAPIDJSON library not found.  Octave will not be able to read and
>      write JSON files.],
>     [rapidjson/rapidjson.h])
>   AC_LANG_POP([C++])
> 
> 
> but it is still not working, as the default macro wants to check for a
> linkable library, i.e. "-lrapidjson".  This of course fails.
> 
> For now you can assume, that `#include "rapidjson/rapidjson.h"` will
> work and ignore the "configure.ac" part.  Later when merging your
> contribution, this becomes important.
> 
> 
> 
> Dear maintainers,
> 
> Stated the problem above: How do we properly check for a C++ header only
> library?
> 
> 1. General solution: Copy OCTAVE_CHECK_LIB to OCTAVE_CHECK_HEADER_LIB
> and to remove the unnecessary linking check parts.
> 
> 2. RapidJSON solution: Copy necessary parts from OCTAVE_CHECK_LIB.
> 
> 3. Did I miss a better option? ;-)

I think that for header only libraries, you should use AC_CHECK_HEADERS - like 
Abdallah suggested.
See e.g. the checks for (alternative) termio headers:
## Find a termio header to include.

AC_CHECK_HEADERS([termios.h], have_termios_h=yes, have_termios_h=no)
AC_CHECK_HEADERS([termio.h], have_termio_h=yes, have_termio_h=no)
AC_CHECK_HEADERS([sgtty.h], have_sgtty_h=yes, have_sgtty_h=no)
AC_CHECK_HEADERS([conio.h], have_conio_h=yes, have_conio_h=no)

Is there a reason this won't work for RapidJSON?

Markus



reply via email to

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