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: Kai Torben Ohlhus
Subject: Re: Extending configure.ac to check for C++ header only libraries
Date: Fri, 22 May 2020 16:40:25 +0900
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

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? ;-)

Thanks for your help,
Kai


[1] https://rapidjson.org/
[2]
https://hg.savannah.gnu.org/hgweb/octave/file/70908e5d8865/m4/acinclude.m4#l414
[3] https://stackoverflow.com/a/6129834/3778706



reply via email to

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