Merge pull request #750 from libexpat/tests-cxx-11

tests: Require a C++11 compiler
This commit is contained in:
Sebastian Pipping 2023-09-21 22:47:48 +02:00 committed by GitHub
commit 298f407021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1070 additions and 4 deletions

View file

@ -4,6 +4,7 @@ BYTEORDER
const
HAVE_ARC4RANDOM
HAVE_ARC4RANDOM_BUF
HAVE_CXX11
HAVE_DLFCN_H
HAVE_FCNTL_H
HAVE_GETPAGESIZE

View file

@ -28,4 +28,4 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
grep -Eo '(define|undef) [a-zA-Z0-9_]+' "${1}" | awk '{print $2}' | sort -u
grep -Eo '(define|undef) [a-zA-Z0-9_]+' "${1}" | awk '{print $2}' | grep -vw if | sort -u

View file

@ -170,6 +170,10 @@ endif()
if(EXPAT_BUILD_TESTS)
# We have to call enable_language() before modifying any CMAKE_CXX_* variables
enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # i.e. -std=c++11 rather than default -std=gnu++11
endif()
#

View file

@ -8,5 +8,7 @@ m4_include(conftools/ax-append-flag.m4)
m4_include(conftools/ax-append-compile-flags.m4)
m4_include(conftools/ax-append-link-flags.m4)
m4_include(conftools/expatcfg-compiler-supports-visibility.m4)
m4_include(conftools/ax-cxx-compile-stdcxx.m4)
m4_include(conftools/ax-cxx-compile-stdcxx-11.m4)
### end of file

View file

@ -180,6 +180,8 @@ AC_ARG_WITH([tests],
[with_tests=yes])
AM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes])
AS_IF([test x${with_tests} = xyes],
[AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])])
AS_VAR_SET([EXPATCFG_ON_MINGW],[no])
AS_CASE("${host_os}",

View file

@ -0,0 +1,39 @@
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 18
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])

File diff suppressed because it is too large Load diff

View file

@ -159,7 +159,7 @@ _run() {
${with_unsigned_char} && BASE_FLAGS="${BASE_FLAGS} -funsigned-char"
local CFLAGS="-std=c99 ${BASE_FLAGS}"
local CXXFLAGS="-std=c++98 ${BASE_FLAGS}"
local CXXFLAGS="-std=c++11 ${BASE_FLAGS}"
(
set -e

View file

@ -76,7 +76,7 @@ populate_environment() {
;;
esac
: ${BASE_COMPILE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings -Wno-long-long"}
: ${BASE_COMPILE_FLAGS:="-pipe -Wall -Wextra -pedantic -Wno-overlength-strings"}
: ${BASE_LINK_FLAGS:=}
if [[ ${QA_COMPILER} = clang ]]; then
@ -114,7 +114,7 @@ populate_environment() {
CFLAGS="-std=c99 ${BASE_COMPILE_FLAGS} ${CFLAGS:-}"
CXXFLAGS="-std=c++98 ${BASE_COMPILE_FLAGS} ${CXXFLAGS:-}"
CXXFLAGS="-std=c++11 ${BASE_COMPILE_FLAGS} ${CXXFLAGS:-}"
LDFLAGS="${BASE_LINK_FLAGS} ${LDFLAGS:-}"
}