Skip to content

Commit

Permalink
Generate config checks based on feature test macros.
Browse files Browse the repository at this point in the history
Uses the C++ feature test macros to generate configuration checks in
both autoconf and CMake.
  • Loading branch information
jtv committed Nov 11, 2023
1 parent 7586846 commit a6e4a11
Show file tree
Hide file tree
Showing 25 changed files with 562 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SUBDIRS = include src test tools config doc
EXTRA_DIST = autogen.sh configitems README.md VERSION requirements.json
EXTRA_DIST = \
autogen.sh configitems cxx_features.txt README.md VERSION requirements.json

MAINTAINERCLEANFILES = \
Makefile.in aclocal.m4 config.h.in config.log configure stamp-h.in
Expand Down
5 changes: 4 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/m4/libtool.m4 \
$(top_srcdir)/config/m4/ltsugar.m4 \
$(top_srcdir)/config/m4/ltversion.m4 \
$(top_srcdir)/config/m4/lt~obsolete.m4 \
$(top_srcdir)/pqxx_generated_checks.ac \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
Expand Down Expand Up @@ -554,7 +555,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
with_postgres_lib = @with_postgres_lib@
SUBDIRS = include src test tools config doc
EXTRA_DIST = autogen.sh configitems README.md VERSION requirements.json
EXTRA_DIST = \
autogen.sh configitems cxx_features.txt README.md VERSION requirements.json

MAINTAINERCLEANFILES = \
Makefile.in aclocal.m4 config.h.in config.log configure stamp-h.in

Expand Down
1 change: 1 addition & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ expand_templates $(find . -name \*.template)
substitute include/pqxx/version.hxx.template >include/pqxx/version.hxx
substitute include/pqxx/doc/mainpage.md.template >include/pqxx/doc/mainpage.md

./tools/generate_cxx_checks.py

autoheader
libtoolize --force --automake --copy
Expand Down
4 changes: 4 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ try_compile(
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/cmp.cxx)

# Incorporate feature checks based on C++ feature test macros. The
# generate_cxx_checks.py script produces these based on cxx_features.txt.
include(pqxx_generated_checks)

try_compile(
need_fslib
${PROJECT_BINARY_DIR}
Expand Down
35 changes: 35 additions & 0 deletions cmake/pqxx_generated_checks.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
try_compile(
PQXX_HAVE_CONCEPTS
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_CONCEPTS.cxx
)

try_compile(
PQXX_HAVE_MULTIDIM
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_MULTIDIM.cxx
)

try_compile(
PQXX_HAVE_SOURCE_LOCATION
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_SOURCE_LOCATION.cxx
)

try_compile(
PQXX_HAVE_SPAN
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_SPAN.cxx
)

try_compile(
PQXX_HAVE_SSIZE
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_SSIZE.cxx
)

try_compile(
PQXX_HAVE_UNREACHABLE
${PROJECT_BINARY_DIR}
SOURCES ${PROJECT_SOURCE_DIR}/config-tests/PQXX_HAVE_UNREACHABLE.cxx
)
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_CONCEPTS.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_concepts'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.388992 UTC.
#include <version>
#if !defined(PQXX_HAVE_CONCEPTS) || !PQXX_HAVE_CONCEPTS
#error "No support for __cpp_concepts detected."
#endif

int main() {}
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_MULTIDIM.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_multidimensional_subscript'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389103 UTC.
#include <version>
#if !defined(PQXX_HAVE_MULTIDIM) || !PQXX_HAVE_MULTIDIM
#error "No support for __cpp_multidimensional_subscript detected."
#endif

int main() {}
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_SOURCE_LOCATION.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_lib_source_location'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389166 UTC.
#include <version>
#if !defined(PQXX_HAVE_SOURCE_LOCATION) || !PQXX_HAVE_SOURCE_LOCATION
#error "No support for __cpp_lib_source_location detected."
#endif

int main() {}
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_SPAN.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_lib_span'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389230 UTC.
#include <version>
#if !defined(PQXX_HAVE_SPAN) || !PQXX_HAVE_SPAN
#error "No support for __cpp_lib_span detected."
#endif

int main() {}
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_SSIZE.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_lib_ssize'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389294 UTC.
#include <version>
#if !defined(PQXX_HAVE_SSIZE) || !PQXX_HAVE_SSIZE
#error "No support for __cpp_lib_ssize detected."
#endif

int main() {}
8 changes: 8 additions & 0 deletions config-tests/PQXX_HAVE_UNREACHABLE.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Feature check for '__cpp_lib_unreachable'.
// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389360 UTC.
#include <version>
#if !defined(PQXX_HAVE_UNREACHABLE) || !PQXX_HAVE_UNREACHABLE
#error "No support for __cpp_lib_unreachable detected."
#endif

int main() {}
1 change: 1 addition & 0 deletions config/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/m4/libtool.m4 \
$(top_srcdir)/config/m4/ltsugar.m4 \
$(top_srcdir)/config/m4/ltversion.m4 \
$(top_srcdir)/config/m4/lt~obsolete.m4 \
$(top_srcdir)/pqxx_generated_checks.ac \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
Expand Down
4 changes: 4 additions & 0 deletions configitems
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ PQXX_HAVE_CXA_DEMANGLE internal compiler
PQXX_HAVE_GCC_PURE public compiler
PQXX_HAVE_GCC_VISIBILITY public compiler
PQXX_HAVE_LIKELY public compiler
PQXX_HAVE_MULTIDIM public compiler
PQXX_HAVE_PATH public compiler
PQXX_HAVE_POLL internal compiler
PQXX_HAVE_SLEEP_FOR internal compiler
PQXX_HAVE_SOURCE_LOCATION public compiler
PQXX_HAVE_SPAN public compiler
PQXX_HAVE_SSIZE public compiler
PQXX_HAVE_STRERROR_R public compiler
PQXX_HAVE_STRERROR_S public compiler
PQXX_HAVE_THREAD_LOCAL internal compiler
PQXX_HAVE_UNREACHABLE public compiler
PQXX_HAVE_YEAR_MONTH_DAY public compiler
VERSION internal autotools
214 changes: 214 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -18174,6 +18174,220 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
printf "%s\n" "$have_cmp" >&6; }


# Incorporate feature checks based on C++ feature test macros. The
# generate_cxx_checks.py script produces these based on cxx_feaures.txt.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_concepts" >&5
printf %s "checking __cpp_concepts... " >&6; }
PQXX_HAVE_CONCEPTS=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_concepts'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.388992 UTC.

#include <version>

#if !defined(PQXX_HAVE_CONCEPTS) || !PQXX_HAVE_CONCEPTS

#error "No support for __cpp_concepts detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_CONCEPTS 1" >>confdefs.h

else $as_nop
PQXX_HAVE_CONCEPTS=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_CONCEPTS" >&5
printf "%s\n" "$PQXX_HAVE_CONCEPTS" >&6; }

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_multidimensional_subscript" >&5
printf %s "checking __cpp_multidimensional_subscript... " >&6; }
PQXX_HAVE_MULTIDIM=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_multidimensional_subscript'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389103 UTC.

#include <version>

#if !defined(PQXX_HAVE_MULTIDIM) || !PQXX_HAVE_MULTIDIM

#error "No support for __cpp_multidimensional_subscript detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_MULTIDIM 1" >>confdefs.h

else $as_nop
PQXX_HAVE_MULTIDIM=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_MULTIDIM" >&5
printf "%s\n" "$PQXX_HAVE_MULTIDIM" >&6; }

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_lib_source_location" >&5
printf %s "checking __cpp_lib_source_location... " >&6; }
PQXX_HAVE_SOURCE_LOCATION=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_lib_source_location'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389166 UTC.

#include <version>

#if !defined(PQXX_HAVE_SOURCE_LOCATION) || !PQXX_HAVE_SOURCE_LOCATION

#error "No support for __cpp_lib_source_location detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_SOURCE_LOCATION 1" >>confdefs.h

else $as_nop
PQXX_HAVE_SOURCE_LOCATION=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_SOURCE_LOCATION" >&5
printf "%s\n" "$PQXX_HAVE_SOURCE_LOCATION" >&6; }

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_lib_span" >&5
printf %s "checking __cpp_lib_span... " >&6; }
PQXX_HAVE_SPAN=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_lib_span'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389230 UTC.

#include <version>

#if !defined(PQXX_HAVE_SPAN) || !PQXX_HAVE_SPAN

#error "No support for __cpp_lib_span detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_SPAN 1" >>confdefs.h

else $as_nop
PQXX_HAVE_SPAN=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_SPAN" >&5
printf "%s\n" "$PQXX_HAVE_SPAN" >&6; }

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_lib_ssize" >&5
printf %s "checking __cpp_lib_ssize... " >&6; }
PQXX_HAVE_SSIZE=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_lib_ssize'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389294 UTC.

#include <version>

#if !defined(PQXX_HAVE_SSIZE) || !PQXX_HAVE_SSIZE

#error "No support for __cpp_lib_ssize detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_SSIZE 1" >>confdefs.h

else $as_nop
PQXX_HAVE_SSIZE=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_SSIZE" >&5
printf "%s\n" "$PQXX_HAVE_SSIZE" >&6; }

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking __cpp_lib_unreachable" >&5
printf %s "checking __cpp_lib_unreachable... " >&6; }
PQXX_HAVE_UNREACHABLE=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
// Feature check for '__cpp_lib_unreachable'.

// Generated by generate_cxx_checks.py at 2023-11-11 02:23:59.389360 UTC.

#include <version>

#if !defined(PQXX_HAVE_UNREACHABLE) || !PQXX_HAVE_UNREACHABLE

#error "No support for __cpp_lib_unreachable detected."

#endif



int main() {}


_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

printf "%s\n" "#define PQXX_HAVE_UNREACHABLE 1" >>confdefs.h

else $as_nop
PQXX_HAVE_UNREACHABLE=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PQXX_HAVE_UNREACHABLE" >&5
printf "%s\n" "$PQXX_HAVE_UNREACHABLE" >&6; }



# Doing my own check for poll(). There's one built into autoconf-archive, but
# it produces warnings in C++ (about unnecessarily using "struct", and using 0
# as a null pointer constant). In maintainer mode, those warnings turn into
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ AC_COMPILE_IFELSE(
AC_MSG_RESULT($have_cmp)


# Incorporate feature checks based on C++ feature test macros. The
# generate_cxx_checks.py script produces these based on cxx_feaures.txt.
m4_include([pqxx_generated_checks.ac])


# Doing my own check for poll(). There's one built into autoconf-archive, but
# it produces warnings in C++ (about unnecessarily using "struct", and using 0
# as a null pointer constant). In maintainer mode, those warnings turn into
Expand Down
Loading

0 comments on commit a6e4a11

Please sign in to comment.