Skip to content

Commit

Permalink
configure.in: Allow using catch2 from system.
Browse files Browse the repository at this point in the history
* configure.in (--with-catch2): New option.
[PKG_CONFIG]: Search catch2 via pkg-config, fall back to use bundled
copy.  Add a new WX_TEST_CXXFLAGS Autoconf variable to configure the
include directory.
* build/bakefiles/config.bkl (WX_TEST_CXXFLAGS): Add option.
* tests/test.bkl [autoconf]: Add WX_TEST_CXXFLAGS option to cxxflags.
* configure: Regenerate via ./autogen.sh.
* tests/Makefile.in: Likewise.
  • Loading branch information
Apteryks committed Jun 19, 2023
1 parent c1fd387 commit 3f20bb6
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 36 deletions.
1 change: 1 addition & 0 deletions build/bakefiles/config.bkl
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ compiled .lib files and setup.h under the lib/ toplevel directory.
<option name="WX_CFLAGS"/>
<option name="WX_CXXFLAGS"/>
<option name="WX_LDFLAGS"/>
<option name="WX_TEST_CXXFLAGS"/>
<option name="HOST_SUFFIX"/>
<option name="DYLIB_RPATH_INSTALL"/>
<option name="DYLIB_RPATH_POSTLINK"/>
Expand Down
171 changes: 160 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,9 @@ enable_option_checking=fatal
ac_subst_vars='subdirs_extra
LTLIBOBJS
LIBOBJS
CATCH2_LIBS
CATCH2_CFLAGS
WX_TEST_CXXFLAGS
RESCOMP
DLLTOOL
GCC
Expand Down Expand Up @@ -1117,6 +1120,7 @@ enable_nanox
with_libpng
with_libjpeg
with_libtiff
with_catch2
with_libjbig
with_libxpm
with_libiconv
Expand Down Expand Up @@ -1467,7 +1471,9 @@ WEBKIT_LIBS
CAIRO_CFLAGS
CAIRO_LIBS
GST_CFLAGS
GST_LIBS'
GST_LIBS
CATCH2_CFLAGS
CATCH2_LIBS'
ac_subdirs_all='src/expat/expat'

# Initialize some variables set by options.
Expand Down Expand Up @@ -2385,6 +2391,7 @@ Optional Packages:
--with-libpng use libpng (PNG image format)
--with-libjpeg use libjpeg (JPEG file format)
--with-libtiff use libtiff (TIFF file format)
--with-catch2 use catch2 (testing framework)
--without-libjbig don't use libjbig in libtiff even if available
--with-libxpm use libxpm (XPM file format)
--with-libiconv use libiconv (character conversion)
Expand Down Expand Up @@ -2514,6 +2521,9 @@ Some influential environment variables:
CAIRO_LIBS linker flags for CAIRO, overriding pkg-config
GST_CFLAGS C compiler flags for GST, overriding pkg-config
GST_LIBS linker flags for GST, overriding pkg-config
CATCH2_CFLAGS
C compiler flags for CATCH2, overriding pkg-config
CATCH2_LIBS linker flags for CATCH2, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -4266,6 +4276,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu




# Make sure we can run config.sub.
$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 ||
as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5
Expand Down Expand Up @@ -4416,6 +4427,7 @@ SAMPLES_CXXFLAGS=
SAMPLES_RPATH_FLAG=
DYLIB_RPATH_INSTALL=
DYLIB_RPATH_POSTLINK=
WX_TEST_CXXFLAGS=

case "${host}" in
*-hp-hpux* )
Expand Down Expand Up @@ -5324,6 +5336,43 @@ fi
eval "$wx_cv_use_libtiff"



# Check whether --with-catch2 was given.
if test ${with_catch2+y}
then :
withval=$with_catch2;
if test "$withval" = yes; then
wx_cv_use_catch2='wxUSE_CATCH2=yes'
elif test "$withval" = no; then
wx_cv_use_catch2='wxUSE_CATCH2=no'
elif test "$withval" = sys; then
wx_cv_use_catch2='wxUSE_CATCH2=sys'
elif test "$withval" = builtin; then
wx_cv_use_catch2='wxUSE_CATCH2=builtin'
else
as_fn_error $? "Invalid value for --with-catch2: should be yes, no, sys, or builtin" "$LINENO" 5
fi

else $as_nop

if test "DEFAULT_wxUSE_CATCH2" = no; then
value=no
elif test "$wxUSE_ALL_FEATURES" = no; then
value=no
elif test "$wxUSE_SYS_LIBS" = no; then
value=builtin
else
value=yes
fi

wx_cv_use_catch2="wxUSE_CATCH2=$value"

fi


eval "$wx_cv_use_catch2"


if test "$wxUSE_LIBTIFF" = "builtin" ; then
wxUSE_LIBJBIG=no
else
Expand Down Expand Up @@ -15849,11 +15898,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx11+y}
if test ${ac_cv_prog_cxx_11+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_cxx11=no
ac_cv_prog_cxx_11=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -15895,11 +15944,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx98+y}
if test ${ac_cv_prog_cxx_98+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_cxx98=no
ac_cv_prog_cxx_98=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -44835,6 +44884,7 @@ SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq






{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
Expand Down Expand Up @@ -44909,23 +44959,122 @@ fi
if test "$wxUSE_TESTS_SUBDIR" != "no"; then
SUBDIRS="$SUBDIRS tests"

if test "$wxUSE_CATCH2" != "builtin"; then
if test -n "$PKG_CONFIG"; then

pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CATCH2" >&5
printf %s "checking for CATCH2... " >&6; }

if test -n "$PKG_CONFIG"; then
if test -n "$CATCH2_CFLAGS"; then
pkg_cv_CATCH2_CFLAGS="$CATCH2_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"catch2 < 3\""; } >&5
($PKG_CONFIG --exists --print-errors "catch2 < 3") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_CATCH2_CFLAGS=`$PKG_CONFIG --cflags "catch2 < 3" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$CATCH2_LIBS"; then
pkg_cv_CATCH2_LIBS="$CATCH2_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"catch2 < 3\""; } >&5
($PKG_CONFIG --exists --print-errors "catch2 < 3") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_CATCH2_LIBS=`$PKG_CONFIG --libs "catch2 < 3" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
CATCH2_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "catch2 < 3"`
else
CATCH2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "catch2 < 3"`
fi
# Put the nasty error message in config.log where it belongs
echo "$CATCH2_PKG_ERRORS" >&5


if test "$wxUSE_CATCH2" = "sys"; then
as_fn_error $? "system catch2 library not found! \
Use --with-catch2=builtin to use built-in version" "$LINENO" 5
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: system catch2 library not found, \
will use built-in instead" >&5
printf "%s\n" "$as_me: WARNING: system catch2 library not found, \
will use built-in instead" >&2;}
wxUSE_CATCH2=builtin
fi
elif test $pkg_failed = untried; then

if test "$wxUSE_CATCH2" = "sys"; then
as_fn_error $? "system catch2 library not found! \
Use --with-catch2=builtin to use built-in version" "$LINENO" 5
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: system catch2 library not found, \
will use built-in instead" >&5
printf "%s\n" "$as_me: WARNING: system catch2 library not found, \
will use built-in instead" >&2;}
wxUSE_CATCH2=builtin
fi
else
CATCH2_CFLAGS=$pkg_cv_CATCH2_CFLAGS
CATCH2_LIBS=$pkg_cv_CATCH2_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
:
fi
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: system catch2 library not found, will use built-in instead" >&5
printf "%s\n" "$as_me: WARNING: system catch2 library not found, will use built-in instead" >&2;}
wxUSE_CATCH2=builtin
fi
fi
if test "$wxUSE_CATCH2" = "builtin"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether catch2/catch.hpp exists" >&5
printf %s "checking whether catch2/catch.hpp exists... " >&6; }
if ! test -f "$srcdir/3rdparty/catch/single_include/catch2/catch.hpp" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
if ! test -f "$srcdir/3rdparty/catch/single_include/catch2/catch.hpp"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
as_fn_error $? "
CATCH (C++ Automated Test Cases in Headers) is required, the required file
$srcdir/3rdparty/catch/single_include/catch2/catch.hpp couldn't be found.
as_fn_error $? "
CATCH2 (C++ Automated Test Cases in Headers) is required, but the file
$srcdir/3rdparty/catch/single_include/catch2/catch.hpp cannot be found.

You might need to run

git submodule update --init 3rdparty/catch

to fix this." "$LINENO" 5
else
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
WX_TEST_CXXFLAGS="-I$wx_top_builddir/3rdparty/catch/single_include $WX_TEST_CXXFLAGS"
fi
fi

Expand Down
41 changes: 33 additions & 8 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ SAMPLES_CXXFLAGS=
SAMPLES_RPATH_FLAG=
DYLIB_RPATH_INSTALL=
DYLIB_RPATH_POSTLINK=
WX_TEST_CXXFLAGS=

dnl to support a new system, you need to add its canonical name (as determined
dnl by config.sub or specified by the configure command line) to this "case"
Expand Down Expand Up @@ -514,6 +515,7 @@ dnl ---------------------------------------------------------------------------
WX_ARG_SYS_WITH(libpng, [ --with-libpng use libpng (PNG image format)], wxUSE_LIBPNG)
WX_ARG_SYS_WITH(libjpeg, [ --with-libjpeg use libjpeg (JPEG file format)], wxUSE_LIBJPEG)
WX_ARG_SYS_WITH(libtiff, [ --with-libtiff use libtiff (TIFF file format)], wxUSE_LIBTIFF)
WX_ARG_SYS_WITH(catch2, [ --with-catch2 use catch2 (testing framework)], wxUSE_CATCH2)

dnl We don't provide built-in version of this library, so if the use of system
dnl libraries is explicitly disabled, we can't use it at all.
Expand Down Expand Up @@ -2056,6 +2058,7 @@ else
fi

dnl Find pkg-config outside of any conditional. Done before any PKG_* call.
dnl This sets the PKG_CONFIG variable.
PKG_PROG_PKG_CONFIG

dnl When cross-compiling for another system from Linux, don't use .pc files on
Expand Down Expand Up @@ -7998,6 +8001,8 @@ AC_SUBST(DLLTOOL)
AC_SUBST(RESCOMP)
AC_SUBST(WINDRES)

dnl CXXFLAGS for the tests binaries
AC_SUBST(WX_TEST_CXXFLAGS)

dnl MAKE_SET will be replaced with "MAKE=..." or nothing if make sets MAKE
dnl itself (this macro is required if SUBDIRS variable is used in Makefile.am
Expand Down Expand Up @@ -8067,21 +8072,41 @@ if test "$wxUSE_TESTS_SUBDIR" != "no"; then
dnl Configure tests directory
SUBDIRS="$SUBDIRS tests"

dnl Check for catch (C++ Automated Test Cases in Headers) availability.
AC_MSG_CHECKING([whether catch2/catch.hpp exists])
if ! test -f "$srcdir/3rdparty/catch/single_include/catch2/catch.hpp" ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([
CATCH (C++ Automated Test Cases in Headers) is required, the required file
$srcdir/3rdparty/catch/single_include/catch2/catch.hpp couldn't be found.
dnl Check for catch (C++ Automated Test Cases in Headers) availability.
if test "$wxUSE_CATCH2" != "builtin"; then
if test -n "$PKG_CONFIG"; then
dnl TODO: Support catch2 version 3, which does not
dnl ship a catch2/catch.hpp header anymore.
PKG_CHECK_MODULES([CATCH2], [catch2 < 3],, [
if test "$wxUSE_CATCH2" = "sys"; then
AC_MSG_ERROR([system catch2 library not found! \
Use --with-catch2=builtin to use built-in version])
else
AC_MSG_WARN([system catch2 library not found, \
will use built-in instead])
wxUSE_CATCH2=builtin
fi])
else
AC_MSG_WARN([system catch2 library not found, will use built-in instead])
wxUSE_CATCH2=builtin
fi
fi
if test "$wxUSE_CATCH2" = "builtin"; then
AC_MSG_CHECKING([whether catch2/catch.hpp exists])
if ! test -f "$srcdir/3rdparty/catch/single_include/catch2/catch.hpp"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([
CATCH2 (C++ Automated Test Cases in Headers) is required, but the file
$srcdir/3rdparty/catch/single_include/catch2/catch.hpp cannot be found.

You might need to run

git submodule update --init 3rdparty/catch

to fix this.])
else
fi
AC_MSG_RESULT([yes])
WX_TEST_CXXFLAGS="-I$wx_top_builddir/3rdparty/catch/single_include $WX_TEST_CXXFLAGS"
fi
fi

Expand Down

0 comments on commit 3f20bb6

Please sign in to comment.