configure.ac |  113 +++++++++++++++++++++++++++++------------------------------
 1 file changed, 57 insertions(+), 56 deletions(-)

New commits:
commit d0a8c957be6dbc91cc05939468ce99947656481c
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue Nov 15 22:18:08 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Nov 16 08:53:58 2022 +0100

    configure: Allow to override CXXFLAGS_CXX11
    
    (My Clang --with-latest-c++ build against GCC 13 trunk libstdc++ needs to 
use
    -std=c++20 instead of -std=c++2b to work around
    <https://discourse.llvm.org/t/pack-expansion-bug/64910> for now.)
    
    Change-Id: Ib66375fe6e5c3b6b1a24b32fcce051d78390f962
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142752
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/configure.ac b/configure.ac
index 51d5508ad248..cef05a5893d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2691,7 +2691,7 @@ libo_FUZZ_ARG_WITH(lxml,
 libo_FUZZ_ARG_WITH(latest-c++,
     AS_HELP_STRING([--with-latest-c++],
         [Try to enable the latest features of the C++ compiler, even if they 
are not yet part of a
-         published standard.]),,
+         published standard.  This option is ignored when CXXFLAGS_CXX11 is 
set explicitly.]),,
         [with_latest_c__=no])
 
 AC_ARG_WITH(gtk3-build,
@@ -7615,63 +7615,64 @@ dnl 
===================================================================
 dnl C++11
 dnl ===================================================================
 
-AC_MSG_CHECKING([whether $CXX_BASE supports C++17])
-CXXFLAGS_CXX11=
-if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
-    if test "$with_latest_c__" = yes; then
-        CXXFLAGS_CXX11=-std:c++latest
-    else
-        CXXFLAGS_CXX11=-std:c++17
-    fi
-    CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus"
-elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
-    my_flags='-std=c++17 -std=c++1z'
-    if test "$with_latest_c__" = yes; then
-        my_flags="-std=c++23 -std=c++2b -std=c++20 -std=c++2a $my_flags"
-    fi
-    for flag in $my_flags; do
-        if test "$COM" = MSC; then
-            flag="-Xclang $flag"
+if test -z "${CXXFLAGS_CXX11+x}"; then
+    AC_MSG_CHECKING([whether $CXX_BASE supports C++17])
+    if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
+        if test "$with_latest_c__" = yes; then
+            CXXFLAGS_CXX11=-std:c++latest
+        else
+            CXXFLAGS_CXX11=-std:c++17
         fi
-        save_CXXFLAGS=$CXXFLAGS
-        CXXFLAGS="$CXXFLAGS $flag -Werror"
-        if test "$SYSTEM_LIBCMIS" = TRUE; then
-            CXXFLAGS="$CXXFLAGS -DSYSTEM_LIBCMIS $LIBCMIS_CFLAGS"
+        CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus"
+    elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
+        my_flags='-std=c++17 -std=c++1z'
+        if test "$with_latest_c__" = yes; then
+            my_flags="-std=c++23 -std=c++2b -std=c++20 -std=c++2a $my_flags"
         fi
-        AC_LANG_PUSH([C++])
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-            #include <algorithm>
-            #include <functional>
-            #include <vector>
-
-            #if defined SYSTEM_LIBCMIS
-            // See ucb/source/ucp/cmis/auth_provider.hxx:
-            #if !defined __clang__
-            #pragma GCC diagnostic push
-            #pragma GCC diagnostic ignored "-Wdeprecated"
-            #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
-            #endif
-            #include <libcmis/libcmis.hxx>
-            #if !defined __clang__
-            #pragma GCC diagnostic pop
-            #endif
-            #endif
-
-            void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
-                std::sort(v.begin(), v.end(), fn);
-            }
-            ]])],[CXXFLAGS_CXX11=$flag])
-        AC_LANG_POP([C++])
-        CXXFLAGS=$save_CXXFLAGS
-        if test -n "$CXXFLAGS_CXX11"; then
-            break
-        fi
-    done
-fi
-if test -n "$CXXFLAGS_CXX11"; then
-    AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
-else
-    AC_MSG_ERROR(no)
+        for flag in $my_flags; do
+            if test "$COM" = MSC; then
+                flag="-Xclang $flag"
+            fi
+            save_CXXFLAGS=$CXXFLAGS
+            CXXFLAGS="$CXXFLAGS $flag -Werror"
+            if test "$SYSTEM_LIBCMIS" = TRUE; then
+                CXXFLAGS="$CXXFLAGS -DSYSTEM_LIBCMIS $LIBCMIS_CFLAGS"
+            fi
+            AC_LANG_PUSH([C++])
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+                #include <algorithm>
+                #include <functional>
+                #include <vector>
+
+                #if defined SYSTEM_LIBCMIS
+                // See ucb/source/ucp/cmis/auth_provider.hxx:
+                #if !defined __clang__
+                #pragma GCC diagnostic push
+                #pragma GCC diagnostic ignored "-Wdeprecated"
+                #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
+                #endif
+                #include <libcmis/libcmis.hxx>
+                #if !defined __clang__
+                #pragma GCC diagnostic pop
+                #endif
+                #endif
+
+                void f(std::vector<int> & v, std::function<bool(int, int)> fn) 
{
+                    std::sort(v.begin(), v.end(), fn);
+                }
+                ]])],[CXXFLAGS_CXX11=$flag])
+            AC_LANG_POP([C++])
+            CXXFLAGS=$save_CXXFLAGS
+            if test -n "$CXXFLAGS_CXX11"; then
+                break
+            fi
+        done
+    fi
+    if test -n "$CXXFLAGS_CXX11"; then
+        AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
+    else
+        AC_MSG_ERROR(no)
+    fi
 fi
 AC_SUBST(CXXFLAGS_CXX11)
 

Reply via email to