From 04c71e680ce8d47abca807597aa353e03273eb0a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 19 Jan 2023 17:40:13 +1300 Subject: AX_CXX_COMPILE_STDCXX: Fix MSVC with C++17 or later MSVC defaults to C++14 and needs -std:c++NN to enable support for newer versions so add that to the list of options to try. --- m4/ax_cxx_compile_stdcxx.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'm4') diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index a3d964c..a2e068a 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -43,7 +43,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 15 +#serial 16 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -104,8 +104,9 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" -std:c++${alternative}; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, -- cgit v1.2.1 From 3a2674fc7d64171f5cd229590456d106fd4e65d9 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 21 Jan 2023 08:02:16 +1300 Subject: Avoid cache variable name collision AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 was colliding with -std=c++17. Suffix the cache variable name for the former with _MSVC to avoid this. --- m4/ax_cxx_compile_stdcxx.m4 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'm4') diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index a2e068a..a9c990e 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -106,8 +106,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl Cray's crayCC needs "-h std=c++11" dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" -std:c++${alternative}; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" -- cgit v1.2.1