Skip to content

Commit

Permalink
fromYAML: let configure fail if rapidyaml cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Otterbein committed Feb 14, 2023
1 parent d85c89f commit 284a017
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,25 @@ PKG_CHECK_MODULES([EDITLINE], [libeditline], [CXXFLAGS="$EDITLINE_CFLAGS $CXXFLA
[AC_MSG_ERROR([Nix requires libeditline; it was not found via pkg-config, but via its header, but required functions do not work. Maybe it is too old? >= 1.14 is required.])])
])

# Look for rapidyaml, an optional dependency.
# Look for rapidyaml.
have_ryml=
AC_ARG_ENABLE([ryml], AS_HELP_STRING([--disable-ryml], [Do not enable rapidyaml and disable builtins.fromYAML]))
AC_ARG_ENABLE([ryml], AS_HELP_STRING([--disable-ryml], [Do not enable rapidyaml and disable builtins.fromYAML], [have_ryml=1]))
AC_ARG_VAR([RYML_CPPFLAGS], [C/C++ preprocessor flags for RAPIDYAML])
AC_ARG_VAR([RYML_LDFLAGS], [linker flags for RAPIDYAML])
if test "x$enable_ryml" != "xno"; then
if test "x$have_ryml" != "x"; then
AC_LANG_PUSH([C++])
saveCXXFLAGS="$CXXFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
# append RYML_CPPFLAGS to CXXFLAGS because CPPFLAGS are not passed to the C++ compiler
CXXFLAGS="$RYML_CPPFLAGS $CXXFLAGS"
LDFLAGS="$RYML_LDFLAGS $RYML_LDFLAGS"
LIBS="-lryml $LIBS"
AC_CHECK_HEADERS([ryml.hpp], [have_ryml=1], [])
AC_CHECK_HEADERS([ryml.hpp], [true],
[AC_MSG_ERROR([Header of libryml is not found.])])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <ryml.hpp>
]], [[ryml::Tree tree;]])],
[AC_DEFINE([HAVE_RYML], [1], [Use rapidyaml])
AC_SUBST(RYML_LIBS, [-lryml])],
[have_ryml=
CXXFLAGS="$saveCXXFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
AC_MSG_RESULT([rapidyaml is not available])])
[AC_MSG_ERROR([libryml is not found.])])
AC_LANG_POP([C++])
fi
AC_SUBST(HAVE_RYML, [$have_ryml])
Expand Down

0 comments on commit 284a017

Please sign in to comment.